-
Notifications
You must be signed in to change notification settings - Fork 3
/
level_duration.R
72 lines (56 loc) · 2 KB
/
level_duration.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# level duration
library(tidyverse)
library(bigrquery)
billing <- "testproj-223217"
sql <- "SELECT levelId, missionSecondsPlayed
FROM `tactile-external.interview.events`"
#tb <- bq_project_query(billing, sql)
#df <- bq_table_download(tb)
#write_csv(df,"level_duration.csv")
#########################################
df <- read_csv("level_duration.csv")
df %<>%
filter(levelId > 0, levelId < 281) %>%
group_by(levelId) %>%
summarise(m = mean(missionSecondsPlayed,na.rm=T))
duration <- df %>%
mutate(part = factor(case_when(levelId >= 1 & levelId <= 50 ~ "1-50",
levelId >= 51 & levelId <= 100 ~ "51-100",
levelId >= 101 & levelId <= 150 ~ "101-150",
levelId >= 151 & levelId <= 200 ~ "151-200",
levelId >= 201 & levelId <= 250 ~ "201-250",
levelId >= 251 & levelId <= 290 ~ "251-290")))
duration$part <- fct_relevel(duration$part, "1-50","51-100","101-150","151-200","201-250","251-290")
#1-50
duration %>%
filter(part=="1-50") %>%
ggplot(aes(x = levelId, y = m)) +
geom_point(size=1) +
geom_line(size=1.5) +
theme_light() +
theme(axis.text = element_text(size = 14),
axis.title = element_text(size = 16)) +
labs(y="mean duration in seconds")
ggsave("duration1.png",width= 18,height = 10)
#51-100
duration %>%
filter(part=="51-100") %>%
ggplot(aes(x=levelId,y=m)) +
geom_point(size=1) +
geom_line(size=1.5) +
theme_light() +
theme(axis.text = element_text(size = 14),
axis.title = element_text(size = 16)) +
labs(y="mean duration in seconds")
ggsave("duration2.png",width= 18,height = 10)
#101-150
duration %>%
filter(part=="101-150") %>%
ggplot(aes(x=levelId,y=m)) +
geom_point() +
geom_line() +
theme_light() +
theme(axis.text = element_text(size = 14),
axis.title = element_text(size = 16)) +
labs(y="mean duration in seconds")
ggsave("duration3.png", width= 18,height = 10)