# A standard plot
p <- ggplot(mpg, aes(displ, hwy)) +
geom_point()
# --- Wrap examples ------
# Defaults to 1st (cyl) at top, 2nd (drv) on left
p + facet_wrap2(vars(cyl, drv), strip = strip_split())
# Change cyl to left, drv to bottom
p + facet_wrap2(vars(cyl, drv), strip = strip_split(c("left", "bottom")))
# --- Grid examples -----
# Display both strips levels on the left
p + facet_grid2(vars(drv), vars(cyl),
strip = strip_split(c("left", "left")))
# Separate the strips again
p + facet_grid2(vars(cyl, year),
strip = strip_split(c("bottom", "left")))
# Using a dummy variable as a title strip
p + facet_grid2(vars(cyl, "year", year),
strip = strip_split(c("bottom", "left", "left")))
Run the code above in your browser using DataLab