ggplot(pokemon) +
geom_histogram(aes(x = generation_id))
## `stat_bin()` using `bins = 30`. Pick better value `binwidth`.
## Warning: Removed 147 rows containing non-finite outside the scale range
## (`stat_bin()`).
ggplot(pokemon) +
geom_histogram(mapping = aes(x = attack), binwidth = 0.5)
# Missing Values
# Filter for missing secondary types and count them
pokemon %>%
filter(is.na(type_2)) %>%
count(type_1)
## # A tibble: 0 × 2
## # ℹ 2 variables: type_1 <chr>, n <int>
# Boxplot ordered by median
ggplot(data = pokemon) +
geom_boxplot(mapping = aes(x = reorder(type_1, attack, FUN = median, na.rm = TRUE), y = attack)) +
coord_flip()
ggplot(data = pokemon) +
geom_count(mapping = aes(x = type_1, y = egg_group_1))
ggplot(data = pokemon) +
geom_point(aes(x = defense, y = attack), alpha = 1/5)
# Fit a model to isolate the attack/defense relationship and plot the residuals
mod <- lm(attack ~ defense, data = pokemon)
pokemon %>%
add_residuals(mod) %>%
ggplot() +
geom_point(mapping = aes(x = defense, y = resid))