#install.packages("readxl")
library(readxl)
library(tidyverse)
library(plotly)
data <- read_excel("SampleData.xlsx")
glimpse(data)
## Rows: 15
## Columns: 8
## $ Country <chr> "Germany", "France", "United States", "Russia", "M~
## $ `Cost ($)` <dbl> 213.5, 200.3, 197.8, 157.8, 63.5, 61.7, 56.5, 53.5~
## $ `Paid New Users` <dbl> 2885, 3236, 1306, 6058, 3368, 1322, 2204, 2657, 10~
## $ `Total New Users` <dbl> 3509, 4158, 3539, 9512, 5054, 1476, 2833, 5556, 11~
## $ `Total Users` <dbl> 3869, 4674, 4591, 11166, 6017, 1528, 3090, 6664, 1~
## $ `Sessions per User` <dbl> 2.5, 2.7, 3.2, 2.9, 2.8, 2.3, 3.3, 3.2, 2.3, 2.9, ~
## $ `Revenue ($)` <dbl> 263.7, 206.9, 968.7, 163.5, 58.0, 66.0, 51.3, 109.~
## $ `eCPM ($)` <dbl> 3.00, 1.80, 5.70, 0.75, 0.75, 2.50, 1.50, 0.74, 2.~
head(data)
## # A tibble: 6 x 8
## Country `Cost ($)` `Paid New Users` `Total New Users` `Total Users`
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 Germany 214. 2885 3509 3869
## 2 France 200. 3236 4158 4674
## 3 United States 198. 1306 3539 4591
## 4 Russia 158. 6058 9512 11166
## 5 Mexico 63.5 3368 5054 6017
## 6 Belgium 61.7 1322 1476 1528
## # ... with 3 more variables: Sessions per User <dbl>, Revenue ($) <dbl>,
## # eCPM ($) <dbl>
در این گزارش فرض شده است که ستون Cost به معنای هزینه انجام شده توسط ناشر برای تبلیغات و افزایش تعداد نصب بازی بوده و همچنین ستون Paid New Users تعداد کاربرانی را نشان میدهد که اشتراک VIP را خریداری کرده اند.
حالت دیگری که میشد برداشت کرد این بود که paid new users تعداد کاربرانی است که از چنل های تبلیغاتی و با صرف هزینه به دست آمده اند و بقیه مستقیم بازی را دانلود کرده اند که این حالت غیر محتمل به نظر آمد. حالا شاخص های موردنظر را برای هر کشور به دیتا اضافه می کنیم(با فرض این که تمام هزینه انجام شده توسط ناشر صرف تبلیغات شده است.):
data <- data %>%
mutate(CPI = round(`Cost ($)`/`Paid New Users`,3),
ARPU = round(`Revenue ($)`/`Total Users`,3),
Potential_users = round(`Cost ($)`/`eCPM ($)`*1000,0),
IPM = round(`Total New Users`/Potential_users*1000,0))
data[data$Country == "United Kingdom",]$IPM <- NA
g <- ggplot(data, aes(x=reorder(Country, -IPM), y = IPM, fill=Country)) +
geom_bar(stat = 'identity') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1)) +
xlab("Country") +
ggtitle("IPM by Country") +
theme(legend.position = "none") +
theme(plot.title = element_text(hjust = 0.5)) +
geom_hline(yintercept = 60, linetype='dashed',color='red')
ggplotly(g)
data$user_frac <- data$`Total Users`/sum(data$`Total Users`)
data$ymax <- cumsum(data$user_frac)
data$ymin <- c(0,head(data$ymax, n=-1))
ggplot(data, aes(ymax=ymax, ymin=ymin, xmax=4, xmin=3, fill=Country)) +
geom_rect() +
coord_polar(theta="y") +
xlim(c(2, 4)) +
ggtitle("Total number of users by country") +
theme_void() +
theme(plot.title = element_text(hjust = 0.5))
data$rev_frac <- data$`Revenue ($)`/sum(data$`Revenue ($)`)
data$ymax <- cumsum(data$rev_frac)
data$ymin <- c(0,head(data$ymax,n=-1))
ggplot(data, aes(ymax=ymax, ymin=ymin, xmax=4, xmin=3, fill=Country)) +
geom_rect() +
coord_polar(theta="y") +
xlim(c(2, 4)) +
ggtitle("Total revenue by country") +
theme_void() +
theme(plot.title = element_text(hjust = 0.5))
data <- data %>% select(-c(ymax,ymin,user_frac,rev_frac))
data <- data %>% arrange(-`Revenue ($)`)
data$Country <- factor(data$Country, levels = data$Country)
data$cum <- cumsum(data$`Revenue ($)`)
g <- ggplot(data, aes(x=data$Country)) +
geom_bar(aes(y=data$`Revenue ($)`), fill='blue', stat="identity") +
geom_point(aes(y=data$cum), color = rgb(0, 1, 0), pch=16, size=1) +
geom_path(aes(y=data$cum, group=1), colour="slateblue1", lty=3, size=0.9) +
theme(axis.text.x = element_text(angle=45, vjust=0.6)) +
labs(title = "Pareto chart for revenue by country", x = 'Country', y ='Revenue') +
theme(plot.title = element_text(hjust = 0.5))
ggplotly(g)
g <- ggplot(data, aes(x=reorder(Country, CPI), y = CPI, fill=Country)) +
geom_bar(stat = 'identity') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=1)) +
xlab("Country") +
ggtitle("CPI by Country") +
theme(legend.position = "none") +
theme(plot.title = element_text(hjust = 0.5)) +
geom_hline(yintercept = 0.3, linetype='dashed',color='green') +
geom_hline(yintercept = 0.4, linetype='dashed',color='red')
ggplotly(g)
## Warning: Removed 1 rows containing missing values (position_stack).