Intro to R and ggplot2 - Application on rogramatic Ad

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))

fig. num of medias by media types

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))

fig. spent distribution by media types

Extention: box plot and violin plot


fig. boxplot
fig. 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.

fig. mapping ctr & spent

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")

fig. mapping ctr & req_per_capita & spent


origin: 

[1] https://www.r-project.org/about.html

[2] https://rstudio.com/products/rstudio/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。