-
Notifications
You must be signed in to change notification settings - Fork 3
/
clv_arpu.R
53 lines (36 loc) · 1.14 KB
/
clv_arpu.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# CLV and Average Revenue Per User (ARPU) and Average Revenue Per Paying User (ARPPU)
library(tidyverse)
library(bigrquery)
billing <- "testproj-223217"
sql <- "SELECT userid, productAmount, productCategory, itemAmount, itemType
FROM `tactile-external.interview.events`
WHERE eventName = 'transaction'"
#tb <- bq_project_query(billing, sql)
#df <- bq_table_download(tb)
#write_csv(df,"clv_arpu.csv")
#################################
df <- read_csv("clv_arpu.csv")
length(unique(df$userid))
# 8464 paying players
# 399465 total players
# percentage = 8464/399465*100 = 2.1
df %<>% filter(productCategory=="REAL_CURRENCY") %>%
select(-itemAmount, -itemType, -productCategory)
df$productAmount <- as.numeric(df$productAmount)
# ARPPU
arppu <- df %>%
group_by(userid) %>%
summarise(total = sum(productAmount))
arppu %>%
ggplot(aes(x=total)) +
geom_density(fill="#9E3896") +
xlim(c(0,5000)) +
theme_light() +
labs(x="Total revenue", y="") +
theme(axis.text = element_text(size = 14),
axis.title = element_text(size = 16))
ggsave("arppu.png")
summary(arppu$total)
# ARPU
sum(arppu$total) / 399465
# ARPU = 93.9