knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
Create ggplot2 plots in a loop.
ggloop allows the user to use create multiple 'ggplot2' plots. Plots are created by passing multiple aesthetics via a vector of aesthetics to ggloop(). Users can use both dplyr-like syntax (i.e. x = mpg:hp, y = 1, color = 4:8, etc) and ggplot2-like syntax (i.e x = mpg/cyl, y = wt + hp, color = factor(cyl), etc).
## CRAN install.packages("ggloop") ## GitHub devtools::install_github("seasmith/ggloop")
You can see ggloop in action with the intro vignette (vignette("intro", "ggloop")). You can also see the example and the very brief overview available below.
library(ggloop) library(ggplot2) g <- ggloop(data = mtcars, mappings = aes_loop(x = c(mpg:hp, mpg/cyl), y = c(hp:mpg, disp/hp), color = gear), remap_xy = FALSE) g <- g + geom_point() g$color.gear$x.mpg_y.hp
ggloop has three exported functions:
ggloop(data, mappings = aes_loop(), remap_xy = TRUE, remap_dots = FALSE, ..., environment = parent.frame() )ggplot2::ggplot() and its arguments.x, y, and ... arguments of length one or less.... argument in aes_loop().... argument is supplied. ... names sit on the top-level of the nested list (they divide the list into however many parts based on the number of such arguments and the remapping behavior). x and y sit at the bottom-level of the nested listaes_loop()aes()c() and NOT have any nested c().dplyr-like = mpg:hp, 1, 5:9, cyl, etc.ggplot2-like = factor(cyl), gear + cyl, etc.c() as a wrapper and only c().%L+%+ operator for a nested list, list, or single 'ggplot' object.Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.