-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraph.R
250 lines (175 loc) · 6.22 KB
/
graph.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
library(ggplot2)
library(dplyr)
df = read.csv("export.csv", stringsAsFactors = FALSE)
#check it out and see where the data is
df.g = df %>%
group_by(platform, metric) %>%
summarize(rows = n())
twitter = df %>%
filter(platform == "twitter.com") %>%
collect()
twitter$Date = as.POSIXct(twitter$timestamp, origin = "1970-01-01 00:00:00")
#@decredproject needs its own treatment
dc = twitter %>%
filter(account == "decredproject" & metric == "followers")
p.dc = ggplot(dc)+
aes(x = Date, y = value)+
geom_line()+
geom_point()+
ylim(30000, 43000)+
ylab("Followers")+labs(title = "Followers for @decredproject twitter account")
ggsave("twitter-decredproject.png", width = 8, height = 6)
twitter.regional = twitter %>%
filter(tags == "regional")
p.twitter.regional = ggplot(twitter.regional)+
aes(x = Date, y = value, colour = account)+
geom_line()+
geom_point()+
facet_grid(metric~., scales = "free_y")+
labs(title = "Twitter account stats")
ggsave("twitter-regional.png", width = 8, height = 6)
twitter.rest = twitter %>%
filter(account != "decredproject" & tags != "regional")
#pi_crumbs has much longer span of data, so doesn't fit well on a graph with the other accounts
twitter.filtered = twitter.rest %>%
filter(account != "pi_crumbs")
p.twitter.rest = ggplot(twitter.filtered)+
aes(x = Date, y = value, colour = account)+
geom_line()+
geom_point()+
facet_grid(metric~., scales = "free_y")+
labs(title = "Twitter account stats")
ggsave("twitter-other.png", width = 8, height = 6)
df.notwitter = df %>%
filter(platform != "twitter.com")
df$Date = as.POSIXct(df$timestamp, origin = "1970-01-01 00:00:00")
#facet wrap by platform, colour by account, shape by metric
#facebook
df.facebook = df %>%
filter(platform == "facebook.com")
#following measures have too few data-points to plot and are filtered out
df.facebook.filtered = df.facebook %>%
filter(metric != "active_7d" & metric != "members" & metric != "posts_30d")
p.facebook = ggplot(df.facebook.filtered)+
aes(x = Date, y = value, colour = account)+
facet_grid(metric ~ .)+
geom_line()+
geom_point()+
labs(title = "Facebook")
ggsave("facebook.png", width = 8, height = 6)
#just posts_30d as it has some data
df.facebook.posts30d = df.facebook %>%
filter(metric == "posts_30d")
p.facebook.posts30d = ggplot(df.facebook.posts30d)+
aes(x = Date, y = value, colour = account)+
facet_grid(metric ~ .)+
geom_line()+
geom_point()+
labs(title = "Facebook")
ggsave("facebook-posts30d.png", width = 8, height = 6)
#t.me
df.tele = df %>%
filter(platform == "t.me")
#Decred is bigger than the rest so could use its own graph
df.tele.decred = df.tele %>%
filter(account == "Decred")
p.tele.decred = ggplot(df.tele.decred)+
aes(x = Date, y = value, colour = account)+
geom_line()+
geom_point()+
facet_grid(metric ~ ., scales = "free_y")+
labs(title = "Telegram")
ggsave("telegram-Decred.png", width = 8, height = 6)
df.tele.rest = df.tele %>%
filter(account != "Decred")
p.tele = ggplot(df.tele.rest)+
aes(x = Date, y = value, colour = account)+
geom_line()+
geom_point()+
facet_grid(metric ~ ., scales = "free_y")+
labs(title = "Telegram")
ggsave("telegram.png", width = 8, height = 6)
df.insta = df %>%
filter(platform == "instagram.com")
p.insta = ggplot(df.insta)+
aes(x = Date, y = value, colour = account)+
geom_line()+
geom_point()+
facet_grid(metric ~ ., scales = "free_y")+
labs(title = "Instagram")
ggsave("instagram.png", width = 8, height = 6)
df.discord = df %>%
filter(platform == "discord")
p.discord = ggplot(df.discord)+
aes(x = Date, y = value, colour = account)+
geom_line()+
geom_point()+
facet_grid(metric ~ ., scales = "free_y")+
labs(title = "Discord")
ggsave("discord.png", width = 8, height = 6)
df.github = df %>%
filter(platform == "github.com")
p.github = ggplot(df.github)+
aes(x = Date, y = value, colour = account)+
geom_line()+
geom_point()+
facet_grid(metric ~ ., scales = "free_y")+
labs(title = "github")
ggsave("github.png", width = 8, height = 6)
df.linkedin = df %>%
filter(platform == "linkedin.com")
p.linkedin = ggplot(df.linkedin)+
aes(x = Date, y = value, colour = account)+
geom_line()+
geom_point()+
facet_grid(metric ~ ., scales = "free_y")+
labs(title = "linkedin")
ggsave("linkedin.png", width = 8, height = 6)
df.vk = df %>%
filter(platform == "vk.com")
#remove isolated data-points
df.vk.filtered = df.vk %>%
filter(metric != "unique_views" & metric != "unique_visitors")
p.vk = ggplot(df.vk.filtered)+
aes(x = Date, y = value, colour = account)+
geom_line()+
geom_point()+
facet_grid(metric ~ ., scales = "free_y")+
labs(title = "vk")
ggsave("vk.png", width = 8, height = 6)
df.youtube = df %>%
filter(platform == "youtube.com")
p.youtube = ggplot(df.youtube)+
aes(x = Date, y = value, colour = account)+
geom_line()+
geom_point()+
facet_grid(metric ~ ., scales = "free_y")+
labs(title = "youtube")
ggsave("youtube.png", width = 8, height = 6)
#medium, discord, matrix, slack, reddit
df.medium = df %>%
filter(platform == "medium.com")
p.medium = ggplot(df.medium)+
aes(x = Date, y = value, colour = account)+
geom_line()+
geom_point()+
facet_grid(metric ~ ., scales = "free_y")+
labs(title = "Medium")
ggsave("medium.png", width = 8, height = 6)
df.rest = df %>%
filter(platform != "twitter.com" & platform != "facebook.com" & platform != "github.com" & platform != "instagram.com" & platform != "vk.com"
& platform != "linkedin.com" & platform != "medium.com" & platform != "t.me" & platform != "youtube.com" & platform != "discord")
df.rest$Date = as.POSIXct(df.rest$timestamp, origin = "1970-01-01 00:00:00")
#need to trim some metrics so there are enough shapes to go around
df.rest.filter = df.rest %>%
filter(metric != "users-dev" & metric != "users-planetdecred" & metric != "users-proposals" & platform != "politeia")
df.rest.g = df.rest %>%
group_by(platform) %>%
summarize(rows = n())
p.rest = ggplot(df.rest.filter)+
aes(x = Date, y = value, colour = account, shape = metric) +
geom_line()+
geom_point()+
facet_grid(platform ~ ., scales = "free_y")+
labs(title = "All the other platforms being tracked with 1 or 2 metrics")
ggsave("other-platforms.png", width = 8, height = 6)