-
Notifications
You must be signed in to change notification settings - Fork 6
/
code.R
85 lines (62 loc) · 1.53 KB
/
code.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
setwd("~/Developer/nintendo-games-ratings")
library(ggplot2)
library(ggthemes)
library(ggtext)
library(extrafont)
library(ggrepel)
library(stringr)
library(lubridate)
loadfonts()
data = read.csv("data.csv")
data = na.omit(data)
data$platform[which(data$platform == "WII")] = "Wii"
data$platform[which(data$platform == "WIIU")] = "Wii U"
data$platform[which(data$platform == "GC")] = "GameCube"
data$year = as.numeric(str_sub(data$date, start = -4))
data$day_of_week = weekdays(as.Date(data$date, format = "%b %d, %Y"))
data$month = strftime(as.Date(data$date, format = "%b %d, %Y"), "%B")
data$score_ratio = data$meta_score / (data$user_score * 10)
data$count = 1
#----------------------------------------------------------
ggplot(
data,
aes(
x = meta_score,
y = user_score,
color = platform
)
) +
geom_point() +
geom_smooth(
method = lm,
se = FALSE
)
#----------------------------------------------------------
# Aggregate Count by Month & Platform
count_by_month_and_platform = aggregate(
data$count,
by = list(
platform = data$platform,
month = data$month
),
sum
)
count_by_month_and_platform$month = factor(
count_by_month_and_platform$month,
levels = c(
"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"
)
)
ggplot(
count_by_month_and_platform,
aes(
x = month,
y = platform,
fill = x
)
) +
geom_tile()
#----------------------------------------------------------