본문 바로가기
반응형

분류 전체보기123

(R) Ways to change the name of element in a variable / revalue()/ ifelse() >library(MASS)> View(birthwt) > ?birthwt > table(birthwt$race) 1 2 3 96 26 67 > table(birthwt$smoke) 0 1 115 74 The variable 'smoke' express 'smoking status during pregnancy' containing elements 0,1.Actually we cannot really know which elements express 'No smoke' or 'smoke' because they are just numbers. For readers of the graph, I will assign 'NO smoke' to 0 and 'smok.. 2020. 9. 1.
(R) geom_histogram/facet_wrap(vars())/facet_grid(vars())/adjust the position of tick mark -scale_y_continuous(breaks=c()) > ggplot(data=airquality,aes(x=Temp))+geom_histogram() > ggplot(data=airquality,aes(x=Temp))+geom_histogram(binwidth=4,fill="white",colour="black") > ggplot(data=airquality,aes(x=Temp))+geom_histogram(binwidth=4,fill="white",colour="black")+facet_grid(vars(Month)) > ggplot(data=airquality,aes(x=Temp))+geom_histogram(binwidth=4,fill="white",colour="black")+facet_wrap(vars(Month)) - scale_y_contin.. 2020. 9. 1.
(R) add label to dot plots / annotate("text")/geom_text(aes(label=)) This is the file that includes the information on worldwide fertility rate and Life expectancy.I brought this information from https://www.unfpa.org/sites/default/files/pub-pdf/UNFPA_PUB_2020_EN_State_of_World_Population.pdf >install.packages("read_excel")>library(read_excel)> fertility_life View(fertility_life) Add label one by one to the dot plot > ggplot(data=fertility_life,aes(x=Lifeexpectan.. 2020. 9. 1.
(R) Alternatives to overlapped geom_point()/ continuous/ discrete /stat_bin2d()/stat_binhex()/position="jitter" When the density of the graph in a particular range is high, we cannot really figure out how dense it is, and how many dots are in the position. For a solution, we can set alpha and shape of the dots, but the solutions are not enough to solve the limitations. ggplot(data=diamonds,aes(x=x*y*z,y=price))+geom_point()> ggplot(data=diamonds,aes(x=x*y*z,y=price))+geom_point(alpha=0.1)> ggplot(data=dia.. 2020. 8. 31.
반응형