myData <- read_xlsx("../00_data/myData.xlsx")
## New names:
## • `` -> `...7`
myData %>%
ggplot(aes(x = alcohol)) +
geom_bar()
myData %>%
ggplot(mapping = aes(x = quality)) +
geom_histogram(binwidth = .5)
myData %>%
filter(quality > 4) %>%
ggplot(aes(x = quality)) +
geom_histogram(binwidth = .05)
myData %>%
ggplot(mapping = aes(x = quality, color = alcohol)) +
geom_freqpoly()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
myData %>%
# Filter out diamonds > 3 carat
filter(quality > 4) %>%
# Plot
ggplot(aes(x = quality)) +
geom_histogram(binwidth = 1)
myData %>%
ggplot(aes(pH)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
myData %>%
ggplot(aes(pH)) +
geom_histogram() +
coord_cartesian(ylim = c(0, 1))
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
myData %>%
ggplot(aes(x = alcohol, y = fixed_acidity)) +
geom_boxplot()
## Warning: Continuous x aesthetic -- did you forget aes(group=...)?
myData %>%
ggplot(aes(x = alcohol, y = fixed_acidity)) +
geom_boxplot()
## Warning: Continuous x aesthetic -- did you forget aes(group=...)?
myData %>%
filter(alcohol < 14, alcohol > 5) %>%
count(quality, alcohol)%>%
ggplot(aes(x = quality, y = alcohol, fill = n)) +
geom_tile()
myData %>%
ggplot(aes(x = quality, y = fixed_acidity)) +
geom_hex()
myData %>%
filter(quality > 3) %>%
ggplot(aes(x = quality, y = fixed_acidity)) +
geom_boxplot(mapping = aes(group = cut_width(quality, .1)))
## Patterns and models
library(modelr)
mod <- lm(log(fixed_acidity) ~ log(quality), data = myData)
myData2 <- myData %>%
modelr::add_residuals(mod) %>%
mutate(resid = exp(resid))
myData2 %>%
ggplot(aes(quality, resid)) +
geom_point()
myData2 %>%
ggplot(aes(alcohol, resid)) +
geom_boxplot()
## Warning: Continuous x aesthetic -- did you forget aes(group=...)?