Skip to content

Instantly share code, notes, and snippets.

@chelseaparlett
Last active June 23, 2020 17:30
Show Gist options
  • Save chelseaparlett/1964af71317cc0e52e1d803528c7e401 to your computer and use it in GitHub Desktop.
Save chelseaparlett/1964af71317cc0e52e1d803528c7e401 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(palmerpenguins)
library(MASS)
#penguin--------------------------------------------------
penguins <- na.omit(penguins)
ggplot(penguins, aes(x = bill_length_mm, bill_depth_mm)) +
geom_point() +
facet_wrap(sex~species) +
theme_bw() +
ggtitle("Penguin Bill Length and Depth (facet_wrap)")
ggplot(penguins, aes(x = bill_length_mm, bill_depth_mm)) +
geom_point() +
facet_grid(sex~species) +
theme_bw() +
ggtitle("Penguin Bill Length and Depth (facet_grid)")
#cereal----------------------------------------------------
data("UScereal")
ggplot(UScereal, aes(x = fibre, y = sugars)) +
geom_point() +
facet_wrap(vitamins ~ mfr) +
theme_bw() +
ggtitle("Cereal Fibre and Sugars (facet_wrap)")
ggplot(UScereal, aes(x = fibre, y = sugars)) +
geom_point() +
facet_grid(vitamins ~ mfr) +
theme_bw() +
ggtitle("Cereal Fibre and Sugars (facet_grid)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment