본문 바로가기
반응형

분류 전체보기123

(R) Add label to bar graphs / geom_text(aes(label=)) > airquality2%group_by(Month)%>%summarise(mean_temp=mean(Temp)) > airquality2# A tibble: 5 x 2 Month mean_temp 1 5 65.52 6 79.13 7 83.94 8 84.05 9 76.9 > ggplot(data=airquality2,aes(x=Month,y=mean_temp))+geom_bar(stat="identity")+geom_text(aes(label=mean_temp)) > ggplot(data=airquality2,aes(x=Month,y=mean_temp))+geom_bar(stat="identity")+geom_text(aes(label=mean_temp),vjust=1.5)> ggplot(data=air.. 2020. 8. 16.
(R)The way to make proportional stacked bar graph / plyr,ddply, dplyr, mutate, count, group_by I will introduce two ways to make the right graph which shows the percentage of elements in rem_rank in each group in "vore" with the samely based data with the left graph. > mean(msleep$sleep_rem)[1] 1.87541 > msleep%filter(!is.na(sleep_rem))> msleep2%mutate(rem_rank=ifelse(sleep_rem%group_by(vore,rem_rank)> ggplot(data=msleep2,aes(x=vore,y=sleep_rem,fill=rem_rank))+geom_bar(stat="identity") > .. 2020. 8. 16.
(R) adjust width of each bin and distance between bins of bar graph Width of bars is set to 0.9 So If you made the bar graphs without designating width, the width of the bins are automatically made having width=0.9 > airquality2%group_by(Month)%>%summarise(mean_temp=mean(Temp)) > ggplot(data=airquality2,aes(x=Month,y=mean_temp))+geom_bar(stat="identity") >ggplot(data=airquality2,aes(x=Month,y=mean_temp))+geom_bar(stat="identity",width=0.9) > ggplot(data=airquali.. 2020. 8. 16.
(R) divide graph in two parts based on x-axis, exclude guide from bar graph > msleep%filter(!is.na(sleep_rem))> mean(msleep$sleep_rem)[1] 1.87541 > msleep%mutate(sleep_rem_d=sleep_rem-1.87541)> msleep2%mutate(rem_rank=ifelse(sleep_rem_d%group_by(vore,rem_rank)> ggplot(data=msleep2,aes(x=vore,y=sleep_rem_d,fill=rem_rank))+geom_bar(stat="identity") > ggplot(data=msleep2,aes(x=vore,y=sleep_rem_d,fill=rem_rank))+geom_bar(position="dodge",stat="identity") > ggplot(data=mslee.. 2020. 8. 14.
반응형