No known key found for this signature in database
GPG Key ID: 1D7529BE14E2BBA9
2 changed files with
23 additions and
0 deletions
-
R/geom-waffle.R
-
man/geom_waffle.Rd
|
|
@ -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, |
|
|
|
|
|
@ -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} |
|
|
|