What is R?
R is a language and environment for statistical computing and graphics. R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible. [1]
What is Rstudio?
RStudio is an integrated development environment (IDE) for R. It includes a console, syntax-highlighting editor that supports direct code execution, as well as tools for plotting, history, debugging and workspace management. [2]
Apply ggplot2 on Mobile Traffic Operation
ggplot2 is a library in Rstudio for creating graphics, based on the grammar of graphics
1. Compare single index by different groups in bar plot
ggplot(Game)+geom_bar(aes(x=`app_two_type(应用二级分类)`, fill=`app_two_type(应用二级分类)`))+coord_flip() + ggtitle("媒体个数") + theme(text = element_text(size = 9))
2. Compare single index by different groups in box plot
Instead of just looking at the average value, we can explore more about distribution of the index by using boxplot or violin plot.
ggplot(Game)+geom_boxplot(aes(x=`app_two_type(应用二级分类)`, y=`spent(收入)`,fill=`app_two_type(应用二级分类)`))+ylim(1000,50000)+ coord_flip()+ ggtitle("收入分布") + theme(text = element_text(size = 9))
Extention: box plot and violin plot
3. Mapping 2 indexes on dot plot
Instead of looking at index of all media, mapping it with spent or uv helps us to look deeper into the index distribution from bottom media to the tops.
4. Mapping 3 indexes on dot plot
We could map two different indexes to see their relation, while using color or shape to note their mass.
ggplot(data=Game_eliPUZ1, mapping=aes(x=`ctr`, y=`req_per_capita`,colour=`spent`))+geom_point() +ggtitle("banner广告-人均请求与ctr")+scale_color_gradient(low="green", high="red")
origin:
[1] https://www.r-project.org/about.html
[2] https://rstudio.com/products/rstudio/