Boredom Exercise
install.packages('tidyverse')
## Installing package into '/home/rstudio-user/R/x86_64-pc-linux-gnu-library/3.6'
## (as 'lib' is unspecified)
library(tidyverse)
## ── Attaching packages ───────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.0 ✓ purrr 0.3.4
## ✓ tibble 3.0.1 ✓ dplyr 0.8.5
## ✓ tidyr 1.0.3 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ──────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
We try to put ‘displ’ (a continuous variable) on facet
ggplot(data = mpg) +
geom_point(mapping = aes(x = cyl, y = hwy), col ='red') +
facet_wrap(~ displ)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), col = 'pink') +
facet_grid(drv ~ cyl)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), col = 'blue') +
facet_grid(drv ~ .)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), col = 'blue') +
facet_grid(. ~ cyl)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = class), col = 'yellow')
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), col = 'orange') +
facet_wrap(~ class, nrow = 2)
?facet_wrap
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), col = 'red') +
facet_grid(class ~ drv)
Quarantine Exercise