ggplot(data = data) +
geom_bar(mapping = aes(x = sports))
data %>% count(sports)
## # A tibble: 31 × 2
## sports n
## <chr> <int>
## 1 All Track Combined 3599
## 2 Archery 39
## 3 Basketball 9443
## 4 Beach Volleyball 61
## 5 Bowling 385
## 6 Diving 12
## 7 Equestrian 3
## 8 Fencing 168
## 9 Golf 4253
## 10 Gymnastics 64
## # ℹ 21 more rows
ggplot(data = data) +
geom_histogram(mapping = aes(x = rev_men))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(data = data, mapping = aes(x = rev_men, colour = sports)) +
geom_freqpoly()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
data %>%
# Filter out sports > 3 rev_men
filter(rev_men< 3000) %>%
# plot
ggplot(aes(x = rev_men)) +
geom_histogram(binwidth = 100)
data %>%
# Filter out sports > 3 rev_men
filter(rev_women < 5000000) %>%
ggplot(aes(rev_women)) +
geom_histogram(binwidth = 100)
data %>%
ggplot(aes(year)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
data %>%
ggplot(aes(year)) +
geom_histogram() +
coord_cartesian(ylim = c(0,50))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Missing Values
data %>%
# filter(year < 2015 | year > 2020) %>%
mutate(year = ifelse(year < 2015 | year > 2020, NA, year)) %>%
# plot
ggplot(aes(x = state_cd, y= year)) +
geom_point()
data %>%
ggplot(aes(stae_cd = "AL", year = 2019)) +
geom_boxplot()
data %>%
count(rev_men, rev_women) %>%
ggplot(aes(x = rev_men, y = rev_women, fill = n)) +
geom_tile()
library(hexbin)
data %>%
ggplot(aes(x = state_cd, y = year)) +
geom_hex()
data %>%
filter(year < 2019) %>%
ggplot(aes(x = state_cd, y = year)) +
geom_boxplot(aes(group = cut_width(rev_men, 100000)))
library(modelr)
exp_men <- lm(log(rev_men) ~ log(rev_women), data = data)
data2 <- data %>%
modelr::add_residuals(exp_men) %>%
mutate(resid= exp(as.numeric(exp_women)))
data2 %>%
ggplot(aes(rev_women, exp_women)) +
geom_point()
data2 %>%
ggplot(aes(sum_partic_women, exp_women)) +
geom_boxplot()