diff --git a/R/geom-waffle.R b/R/geom-waffle.R index facc546..968dcb1 100644 --- a/R/geom-waffle.R +++ b/R/geom-waffle.R @@ -43,6 +43,17 @@ #' `color = "red"` or `size = 3`. They may also be parameters #' to the paired geom/stat. #' @export +#' @examples +#' data.frame( +#' parts = factor(rep(month.abb[1:3], 3), levels=month.abb[1:3]), +#' values = c(10, 20, 30, 6, 14, 40, 30, 20, 10), +#' fct = c(rep("Thing 1", 3), rep("Thing 2", 3), rep("Thing 3", 3)) +#' ) -> xdf +#' +#' ggplot(xdf, aes(fill = parts, values = values)) + +#' geom_waffle() + +#' facet_wrap(~fct) + +#' coord_equal() geom_waffle <- function( mapping = NULL, data = NULL, n_rows = 10, flip = FALSE, make_proportional = FALSE, diff --git a/man/geom_waffle.Rd b/man/geom_waffle.Rd index d609c77..2f29fa9 100644 --- a/man/geom_waffle.Rd +++ b/man/geom_waffle.Rd @@ -75,4 +75,16 @@ There are two special/critical \code{aes()} mappings: \item \code{values} (which column you're mapping the filling for the squares with) } } +\examples{ +data.frame( + parts = factor(rep(month.abb[1:3], 3), levels=month.abb[1:3]), + values = c(10, 20, 30, 6, 14, 40, 30, 20, 10), + fct = c(rep("Thing 1", 3), rep("Thing 2", 3), rep("Thing 3", 3)) +) -> xdf + +ggplot(xdf, aes(fill = parts, values = values)) + + geom_waffle() + + facet_wrap(~fct) + + coord_equal() +} \keyword{datasets}