-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 17.9 KB
/
.Rhistory
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
group_by(Model) %>% summarise(count_ev = n()) %>% head(10)
EV_County_king
EV_County_king <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Model) %>% summarise(count_ev = n()) %>% head(10)
EV_County_king
EV_County_king <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Model) %>% summarise(count_ev = n()) %>% arrange(-count_ev)
EV_County_king
EV_County_king <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Model) %>% summarise(count_ev = n()) %>%
arrange(-count_ev) %>%
head(10)
EV_County_king
ggplot(data = EV_County_king, mapping = aes(x = Model, y = count_ev)) +
geom_col()
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = Model)) +
geom_col()
EV_County_king_mean <- EV_Population_Clean %>%
filter(County == "King" & Electric.Range > 0) %>% group_by(Model) %>%
summarise(avg_range = mean(Electric.Range, round(2)),
length_model = length(Model))%>%
arrange(-avg_range)
EV_County_king_mean
ggplot(data = EV_County_king_mean, mapping = aes(x = length_model, y = avg_range)) +
geom_point()
EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Make, Electric.Range) %>%
summarise(count_model = n()) %>%
arrange(-count_model) %>%
head(10)
EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Make, Electric.Range) %>%
summarise(count_model = n()) %>%
arrange(-count_model)
EV_Make <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Make, Electric.Range) %>%
summarise(count_model = n()) %>%
arrange(-count_model)
ggplot(data = EV_County_king, mapping = aes(x = count_model, y = Make)) +
geom_boxplotl()
library(ggplot2)
ggplot(data = EV_County_king, mapping = aes(x = count_model, y = Make)) +
geom_boxplotl()
ggplot(data = EV_County_king, mapping = aes(x = count_model, y = Make)) +
geom_boxplotl()
ggplot(data = EV_County_king, mapping = aes(x = count_model, y = Make)) +
geom_boxplot()
ggplot(data = EV_Make, mapping = aes(x = count_model, y = Make)) +
geom_boxplot()
EV_Make <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Make, Electric.Range) %>%
summarise(count_model = n()) %>%
arrange(-count_model) %>% head(10)
ggplot(data = EV_Make, mapping = aes(x = count_model, y = Make)) +
geom_boxplot()
ggplot(data = EV_Make, mapping = aes(x = count_model, y = Make)) +
geom_boxplot()
EV_Make <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Make, Electric.Range) %>%
summarise(count_model = n()) %>%
arrange(-count_model)
ggplot(data = EV_Make, mapping = aes(x = count_model, y = Make)) +
geom_boxplot()
cor(EV_County_king_mean$length_model, EV_County_king_mean$avg_range)
EV_County_king <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Model) %>% summarise(count_ev = n()) %>%
arrange(-count_ev)
EV_County_king
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = Model)) +
geom_col()
EV_County_king <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Model) %>% summarise(count_ev = n()) %>%
arrange(-count_ev) %>%
head(10)
EV_County_king
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = Model)) +
geom_col()
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col()
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col(aes(fill = count_ev), col = "darkred")
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col(aes(fill = count_ev), col = "darkred") +
scale_fill_gradient(low="white", high="salmon")
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col(aes(fill = count_ev), col = "darkred") +
scale_fill_gradient(low="white", high="darkblue")
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col(aes(fill = count_ev), col = "darkred") +
scale_fill_gradient(low="white", high="darkblue")+
geom_label(aes(label = count_ev))
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col(aes(fill = count_ev), col = "darkred") +
scale_fill_gradient(low="white", high="darkblue")+
geom_label(aes(label = count_ev)) +
labs(
title = "Top 10 Model Electrical Vehicle In King COunty",
subtitle = "2012 - 2023",
x = "Total Eelctrical Vehicle",
y = NULL,
caption = "Source: catalog.data.gov"
)
ggplot(data = EV_County_king_mean, mapping = aes(x = length_model, y = avg_range)) +
geom_jitter(mapping = aes(size = avg_range), col = "red", alpha = 0.5)
ggplot(data = EV_County_king_mean, mapping = aes(x = length_model, y = avg_range)) +
geom_jitter(mapping = aes(size = avg_range), col = "red", alpha = 0.5) +
labs(
title = "Average Range Per Count Model Distribution for Each Make",
subtitle = "2012 - 2023",
x = "Count Model",
y = "Average Range",
size = "Comment per Views"
)
ggplot(data = EV_Make, mapping = aes(x = count_model, y = Make)) +
geom_boxplot(fill = "black", col = "red")
ggplot(data = EV_Make, mapping = aes(x = count_model, y = Make)) +
geom_boxplot(fill = "salmon", col = "black")
ggplot(data = EV_Make, mapping = aes(x = count_model, y = Make)) +
geom_boxplot(fill = "salmon", col = "black") +
labs(
title = "Count Model In King County Distribution for Each Model",
subtitle = "2012 - 2023",
x = "Count Model",
y = NULL
)
ggplot(data = EV_County_king_mean, mapping = aes(x = length_model, y = avg_range)) +
geom_jitter(mapping = aes(size = avg_range), col = "red", alpha = 0.5) +
labs(
title = "Average Range Per Count Model Distribution for Each Make",
subtitle = "2012 - 2023",
x = "Count Model",
y = "Average Range",
size = "Comment per Views",
caption = "Source: catalog.data.gov"
)
mean_range <- mean(EV_Population_Clean$Electric.Range)
mean_range
EV_Population_Clean[is.na(EV_Population_Clean)] <- 0
EV_Population_Clean <- mutate(EV_Population_Clean,
County = as.factor(County),
City = as.factor(City),
Make = as.factor(Make),
Model = as.factor(Model))
summary(EV_Population_Clean)
mean_range <- mean(EV_Population_Clean$Electric.Range)
mean_range
sd_range
sd_range <- sd(EV_Population_Clean$Electric.Range)
sd_range
# Delee coloumn
EV_Population_Clean <- select(EV_Population,
-State,
-Postal.Code,
-Legislative.District,
-Vehicle.Location,
-X2020.Census.Tract)
colSums(is.na(EV_Population_Clean))
EV_Population_Clean[is.na(EV_Population_Clean)] <- 0
head(EV_Population_Clean)
colnames(EV_Population_Clean)[7] <- "EV_Type"
colnames(EV_Population_Clean)[8] <- "CAFV"
head(EV_Population_Clean)
# aggregasi data
EV_king_type <- EV_Population_Clean %>%
filter(County == "King") %>%
group_by(Model, EV_Type) %>%
summarise(count_model = n()) %>%
arrange(-count_model)
ggplot(EV_king_type, mapping = aes(x = count_model, y = reorder(Model, count_model)))+
geom_col(aes(fill = EV_type), position = "fill")+
labs(
title = "Total Video Base On Publish Hours Trending Videos",
subtitle = "category Vs Publish Hour",
x = "Total Video",
y = NULL,
fill = "Publish Hour",
caption = "Source: Youtube US Trending"
) + theme_light()
# aggregasi data
EV_king_type <- EV_Population_Clean %>%
filter(County == "King") %>%
group_by(Make, EV_Type) %>%
summarise(count_make = n()) %>%
arrange(-count_make)
ggplot(EV_king_type, mapping = aes(x = count_make, y = reorder(Model, count_make)))+
geom_col(aes(fill = EV_type), position = "fill")+
labs(
title = "Total Video Base On Publish Hours Trending Videos",
subtitle = "category Vs Publish Hour",
x = "Total Video",
y = NULL,
fill = "Publish Hour",
caption = "Source: Youtube US Trending"
) + theme_light()
EV_king_type
ggplot(EV_king_type, mapping = aes(x = count_make, y = reorder(Model, count_make)))+
geom_col(aes(fill = EV_Type), position = "fill")+
labs(
title = "Total Video Base On Publish Hours Trending Videos",
subtitle = "category Vs Publish Hour",
x = "Total Video",
y = NULL,
fill = "Publish Hour",
caption = "Source: Youtube US Trending"
) + theme_light()
ggplot(EV_king_type, mapping = aes(x = count_make, y = reorder(Make, count_make)))+
geom_col(aes(fill = EV_Type), position = "fill")+
labs(
title = "Total Video Base On Publish Hours Trending Videos",
subtitle = "category Vs Publish Hour",
x = "Total Video",
y = NULL,
fill = "Publish Hour",
caption = "Source: Youtube US Trending"
) + theme_light()
# aggregasi data
EV_king_type <- EV_Population_Clean %>%
filter(County == "King") %>%
group_by(Make, EV_Type) %>%
summarise(count_make = n()) %>%
arrange(-count_make) %>%
head(10)
EV_king_type
ggplot(EV_king_type, mapping = aes(x = count_make, y = reorder(Make, count_make)))+
geom_col(aes(fill = EV_Type), position = "fill")+
labs(
title = "Total Video Base On Publish Hours Trending Videos",
subtitle = "category Vs Publish Hour",
x = "Total Video",
y = NULL,
fill = "Publish Hour",
caption = "Source: Youtube US Trending"
) + theme_light()
ggplot(EV_king_type, mapping = aes(x = count_make, y = reorder(Make, count_make)))+
geom_col(aes(fill = EV_Type), position = "fill")+
labs(
title = "Top 10 Make in King County",
subtitle = "Make Vs Electrical Vehicle type",
x = "Total Make",
y = NULL,
fill = "Eelctrical Vehicle Type",
caption = "Source: catalog.data.gov"
) + theme_light()
View(EV_Piopulation)
glimpse(EV_Population)
# clear-up the environment
rm(list = ls())
# chunk options
knitr::opts_chunk$set(
message = FALSE,
warning = FALSE,
fig.align = "center",
comment = "#>"
)
options(scipen = 999)
EV_Population <- read.csv("Electric_Vehicle_Population_Data.csv")
head(EV_Population)
library(tidyverse)
glimpse(EV_Population)
# Delee coloumn
EV_Population_Clean <- select(EV_Population,
-State,
-Postal.Code,
-Legislative.District,
-Vehicle.Location,
-X2020.Census.Tract)
colSums(is.na(EV_Population_Clean))
EV_Population_Clean[is.na(EV_Population_Clean)] <- 0
colnames(EV_Population_Clean)[7] <- "EV_Type"
colnames(EV_Population_Clean)[8] <- "CAFV"
EV_Population_Clean <- mutate(EV_Population_Clean,
County = as.factor(County),
City = as.factor(City),
Make = as.factor(Make),
Model = as.factor(Model))
summary(EV_Population_Clean)
library(ggplot2)
EV_Make <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Make, Electric.Range) %>%
summarise(count_model = n()) %>%
arrange(-count_model)
ggplot(data = EV_Make, mapping = aes(x = count_model, y = Make)) +
geom_boxplot(fill = "salmon", col = "black") +
labs(
title = "Count Model In King County Distribution for Each Model",
subtitle = "2012 - 2023",
x = "Count Model",
y = NULL
)
EV_County_king <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Model) %>% summarise(count_ev = n()) %>%
arrange(-count_ev) %>%
head(10)
EV_County_king
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col(aes(fill = count_ev), col = "darkred") +
scale_fill_gradient(low="white", high="darkblue")+
geom_label(aes(label = count_ev)) +
labs(
title = "Top 10 Model Electrical Vehicle In King COunty",
subtitle = "2012 - 2023",
x = "Total Eelctrical Vehicle",
y = NULL,
caption = "Source: catalog.data.gov"
)
# aggregasi data
EV_king_type <- EV_Population_Clean %>%
filter(County == "King") %>%
group_by(Make, EV_Type) %>%
summarise(count_make = n()) %>%
arrange(-count_make) %>%
head(10)
ggplot(EV_king_type, mapping = aes(x = count_make, y = reorder(Make, count_make)))+
geom_col(aes(fill = EV_Type), position = "fill")+
labs(
title = "Top 10 Make in King County",
subtitle = "Make Vs Electrical Vehicle type",
x = "Total Make",
y = NULL,
fill = "Eelctrical Vehicle Type",
caption = "Source: catalog.data.gov"
) + theme_light()
EV_County_king_mean <- EV_Population_Clean %>%
filter(County == "King" & Electric.Range > 0) %>% group_by(Model) %>%
summarise(avg_range = mean(Electric.Range, round(2)),
length_model = length(Model))%>%
arrange(-avg_range)
EV_County_king_mean
ggplot(data = EV_County_king_mean, mapping = aes(x = length_model, y = avg_range)) +
geom_jitter(mapping = aes(size = avg_range), col = "red", alpha = 0.5) +
labs(
title = "Average Range Per Count Model Distribution for Each Make",
subtitle = "2012 - 2023",
x = "Count Model",
y = "Average Range",
size = "Comment per Views",
caption = "Source: catalog.data.gov"
)
cor(EV_County_king_mean$length_model, EV_County_king_mean$avg_range)
# Aggregation data for county King
EV_Make <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Make, Electric.Range) %>%
summarise(count_make = n()) %>%
arrange(-count_make)
# Plot from EV_Make
ggplot(data = EV_Make, mapping = aes(x = count_make, y = Make)) +
geom_boxplot(fill = "salmon", col = "black") +
labs(
title = "Count Model In King County Distribution for Each Model",
subtitle = "2012 - 2023",
x = "Count Model",
y = NULL
)
# Plot from EV_Make
ggplot(data = EV_Make, mapping = aes(x = count_make, y = Make)) +
geom_boxplot(fill = "salmon", col = "black") +
labs(
title = "Count Model In King County Distribution for Each Make",
subtitle = "2012 - 2023",
x = "Count Model",
y = NULL
)
# Aggregation data for county King
EV_County_king <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Model) %>% summarise(count_ev = n()) %>%
arrange(-count_ev) %>%
head(10)
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col(aes(fill = count_ev), col = "darkred") +
scale_fill_gradient(low="white", high="darkblue")+
geom_label(aes(label = count_ev)) +
labs(
title = "Top 10 Model Electrical Vehicle In King COunty",
subtitle = "2012 - 2023",
x = "Total Eelctrical Vehicle",
y = NULL,
caption = "Source: catalog.data.gov"
)
# Plot form EV_County_king
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col(aes(fill = count_ev), col = "darkred") +
scale_fill_gradient(low="white", high="darkblue")+
geom_label(aes(label = count_ev)) +
labs(
title = "Top 10 Model Electrical Vehicle In King COunty",
subtitle = "2012 - 2023",
x = "Total Eelctrical Vehicle",
y = NULL,
caption = "Source: catalog.data.gov"
)
# Plot form EV_County_king
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col(aes(fill = count_ev), col = "darkred") +
scale_fill_gradient(low="white", high="darkblue")+
geom_label(aes(label = count_ev)) +
labs(
title = "Top 10 Model Electrical Vehicle In King County",
subtitle = "2012 - 2023",
x = "Total Eelctrical Vehicle",
y = NULL,
caption = "Source: catalog.data.gov"
)
# # Aggregation data for county King
EV_king_type <- EV_Population_Clean %>%
filter(County == "King") %>%
group_by(Make, EV_Type) %>%
summarise(count_make = n()) %>%
arrange(-count_make) %>%
head(10)
# Aggregation data for county King
EV_Make <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Make, Electric.Range) %>%
summarise(count_make = n(),.groups = "drop") %>%
arrange(-count_make)
# Plot from EV_Make
ggplot(data = EV_Make, mapping = aes(x = count_make, y = Make)) +
geom_boxplot(fill = "salmon", col = "black") +
labs(
title = "Count Model In King County Distribution for Each Make",
subtitle = "2012 - 2023",
x = "Count Model",
y = NULL
)
# Aggregation data for county King
EV_County_king <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Model) %>% summarise(count_ev = n()) %>%
arrange(-count_ev)
# Plot form EV_County_king
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col(aes(fill = count_ev), col = "darkred") +
scale_fill_gradient(low="white", high="darkblue")+
geom_label(aes(label = count_ev)) +
labs(
title = "Top 10 Model Electrical Vehicle In King County",
subtitle = "2012 - 2023",
x = "Total Eelctrical Vehicle",
y = NULL,
caption = "Source: catalog.data.gov"
)
# Aggregation data for county King
EV_County_king <- EV_Population_Clean %>% filter(County == "King" & Electric.Range > 0) %>%
group_by(Model) %>% summarise(count_ev = n()) %>%
arrange(-count_ev) %>%
head(10)
# Plot form EV_County_king
ggplot(data = EV_County_king, mapping = aes(x = count_ev, y = reorder(Model, count_ev))) +
geom_col(aes(fill = count_ev), col = "darkred") +
scale_fill_gradient(low="white", high="darkblue")+
geom_label(aes(label = count_ev)) +
labs(
title = "Top 10 Model Electrical Vehicle In King County",
subtitle = "2012 - 2023",
x = "Total Eelctrical Vehicle",
y = NULL,
caption = "Source: catalog.data.gov"
)
# # Aggregation data for county King
EV_king_type <- EV_Population_Clean %>%
filter(County == "King") %>%
group_by(Make, EV_Type) %>%
summarise(count_make = n(),.groups = "drop") %>%
arrange(-count_make) %>%
head(10)
ggplot(EV_king_type, mapping = aes(x = count_make, y = reorder(Make, count_make)))+
geom_col(aes(fill = EV_Type), position = "fill")+
labs(
title = "Top 10 Make in King County",
subtitle = "Make Vs Electrical Vehicle type",
x = "Total Make",
y = NULL,
fill = "Eelctrical Vehicle Type",
caption = "Source: catalog.data.gov"
) + theme_light()
EV_County_king_mean <- EV_Population_Clean %>%
filter(County == "King" & Electric.Range > 0) %>% group_by(Model) %>%
summarise(avg_range = mean(Electric.Range, round(2)),
length_model = length(Model))%>%
arrange(-avg_range)
# Plot from EV_County_king_mean
ggplot(data = EV_County_king_mean, mapping = aes(x = length_model, y = avg_range)) +
geom_jitter(mapping = aes(size = avg_range), col = "red", alpha = 0.3) +
labs(
title = "Average Range Per Count Model Distribution for Each Make",
subtitle = "2012 - 2023",
x = "Count Model",
y = "Average Range",
size = "Electrical Range",
caption = "Source: catalog.data.gov"
)
EV_Population_Clean %>%
filter(County == "King") %>%
group_by(Make, CAFV) %>%
summarise(count_cafv = n(),.groups = "drop") %>%
arrange(-count_cafv) %>%
head(10)
EV_king_cafv <- EV_Population_Clean %>%
filter(County == "King") %>%
group_by(Make, CAFV) %>%
summarise(count_cafv = n(),.groups = "drop") %>%
arrange(-count_cafv) %>%
head(10)
# Plot from EV_king_type
ggplot(EV_king_cafv, mapping = aes(x = count_cafv, y = reorder(Make, count_cafv)))+
geom_col(aes(fill = CAFV), position = "fill")+
labs(
title = "Top 10 Make in King County CAFV",
subtitle = "Make Vs CAFV",
x = "Total Make",
y = NULL,
fill = "CAFV",
caption = "Source: catalog.data.gov"
) + theme_light()