# install.packages("palmerpenguins")library(palmerpenguins)data(penguins, package ="palmerpenguins")hchart(penguins,"scatter",hcaes(x =flipper_length_mm, y =bill_length_mm, group =species))
hchart(economics_long2, "line", hcaes(x =date, y =value01, group =variable))
highchart()|>hc_add_series(data =sample(1:12))|>hc_add_series(data =sample(1:12)+10)|>hc_tooltip(# tooltip üzerine çizgi ekler (daha iyi takip edebilmek için) crosshairs =TRUE,# aynı anda tüm değerleri görebilmek için sort =TRUE)
** Farklı özellikler için highcharts sitesinden yararlanılabilir: **
highcharts dataLabels
3.1.5 Dağılım grafiği
density(data$kilo)#> #> Call:#> density.default(x = data$kilo)#> #> Data: data$kilo (200 obs.); Bandwidth 'bw' = 0.5315#> #> x y #> Min. :51.19 Min. :5.707e-05 #> 1st Qu.:53.87 1st Qu.:1.348e-02 #> Median :56.55 Median :8.380e-02 #> Mean :56.55 Mean :9.326e-02 #> 3rd Qu.:59.22 3rd Qu.:1.697e-01 #> Max. :61.90 Max. :2.025e-01
hchart(density(data$kilo), type ="area", name ="Kilo")
library(readr)# Verinin yüklenmesi ve hazırlığıdf<-read_csv("https://raw.githubusercontent.com/mekhatria/demo_highcharts/master/Olympics2012CapitalLetter.csv")#> Rows: 10858 Columns: 8#> ── Column specification ────────────────────────────────────#> Delimiter: ","#> chr (5): name, sport, nationality, sex, date_of_birth#> dbl (3): age, height, weight#> #> ℹ Use `spec()` to retrieve the full column specification for this data.#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.df=subset(df, select =-c(nationality, date_of_birth, name, age))my_data<-df%>%filter((sport=="Gymnastics"&sex=="male")|(sport=="Canoe"&sex=="male")|(sport=="Hockey"&sex=="male")|(sport=="Modern Pentathlon"&sex=="male"))my_data=subset(my_data, select =-c(sex))my_data%>%head()%>%kable()
sport
height
weight
Canoe
2.02
115
Canoe
1.88
102
Canoe
1.88
100
Canoe
1.92
98
Canoe
1.88
98
Canoe
1.84
97
hcboxplot( x =my_data$height, var =my_data$sport, name ="Length", color ="#2980b9", outliers =TRUE)%>%hc_chart(type ="column")%>%# type="bar" olursa yatay eksende gözükür# En üstte bulunan başlıkhc_title(text ="Male height by descipline (Olympic 2012)")%>%# y eksenindeki değişiklikler içinhc_yAxis(title =list(text ="Height in metre"))%>%# Grafiğin üstüne serpilme diyagramı eklemek içinhc_add_series( data =my_data, type ="scatter",hcaes(x ="sport", y ="my_data$height", group ="sport"))%>%# serpilme diyagramı ayarları için scatter = list(...)hc_plotOptions(scatter =list( color ="red", marker =list( radius =2, symbol ="circle", lineWidth =1)))%>%hc_plotOptions(scatter =list(jitter =list(x =.1, y =0)))#> Warning: 'hcboxplot' is deprecated.#> Use 'data_to_boxplot' instead.#> See help("Deprecated")
highchart()|># Datahc_add_series(favorite_pies, "column",hcaes( x =pie, y =percent), name ="Pie")|>hc_add_series(favorite_bars,"pie",hcaes( name =bar, y =percent), name ="Bars")|>hc_plotOptions( series =list( showInLegend =FALSE, pointFormat ="{point.y}%",# her bir kategori için farklı renk colorByPoint =TRUE), pie =list(# pie chart'ın konumu ve boyutu center =c('30%', '10%'), size =120, dataLabels =list(enabled =FALSE)))|># eksenlerhc_yAxis( title =list(text ="percentage of tastiness"), labels =list(format ="{value}%"), max =100)|>hc_xAxis( categories =favorite_pies$pie)|># Titles, subtitle, caption and creditshc_title( text ="How I Met Your Mother: Pie Chart Bar Graph")|>hc_subtitle( text ="This is a bar graph describing my favorite pies including a pie chart describing my favorite bars")|>hc_caption( text ="The values represented are in percentage of tastiness and awesomeness.")|>hc_credits( enabled =TRUE, text ="Source: HIMYM", href ="https://www.youtube.com/watch?v=f_J8QU1m0Ng", style =list(fontSize ="12px"))|>hc_size( height =600)
df<-data.frame( stringsAsFactors =FALSE, name =c("The Left","Social Democratic Party","Alliance 90/The Greens","Free Democratic Party","Christian Democratic Union","Christian Social Union in Bavaria","Alternative for Germany"), count =c(69, 153, 67, 80, 200, 46, 94), col =c("#BE3075", "#EB001F", "#64A12D", "#FFED00","#000000", "#008AC5", "#009EE0"), abbrv =c("DIE LINKE", "SPD", "GRÜNE", "FDP", "CDU", "CSU", "AfD"))hchart(df, type="item",hcaes( name =name, y =count, label =abbrv, color =col), name ="Representatives",# legendda gösterilmesi için showInLegend =TRUE, size ="100%",# pie chartın yerinin grafik alanına göre belirlenmesi (yatay, dikey) center =list("50%", "75%"),# pie chartarın başlama derecesi startAngle =-100,# pie chartın bitiş dercesi endAngle =100)%>%hc_title(text ="Item chart with different layout")%>%hc_legend(labelFormat ='{name} <span style="opacity: 0.4">{y}</span>')
library(forcats)library(stringr)library(purrr)pkmn_min<-as.data.frame(pokemon)|>count(type_1, color =type_1_color)|>mutate(type_1 =fct_reorder(type_1, .x =n))|>arrange(desc(type_1))pkmn_ddn<-pokemon|>count(type_1, type_2, color =type_mix_color)|>arrange(type_1, desc(n))|>mutate(type_2 =ifelse(is.na(type_2), str_c("only ", type_1), type_2))|>group_nest(type_1)|>mutate( id =type_1, type ="column",# in the drilldown we'll give the mapping via creating the columns data =map(data, mutate, name =type_2, y =n), data =map(data, list_parse))hchart(pkmn_min, type ="column",hcaes(x =type_1, y =n, color =color, drilldown =type_1), name ="Pokémons")|>hc_drilldown( activeAxisLabelStyle =list(textDecoration ="none"), allowPointDrilldown =TRUE, series =list_parse(pkmn_ddn))|>hc_yAxis( title =list(text =""), endOnTick =FALSE, opposite =TRUE)|>hc_xAxis( title =list(text =""), endOnTick =FALSE, gridLineWidth =0, tickWidth =0)|>hc_chart( style =list(fontFamily ="Gloria Hallelujah"))