Browse Source

cran checks

pull/65/head
boB Rudis 5 years ago
parent
commit
556514f911
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 3
      DESCRIPTION
  2. 3
      NAMESPACE
  3. 55
      R/geom-pictogram.R
  4. 5
      R/geom-waffle.R
  5. 3
      R/waffle-package.R
  6. 15
      man/draw_key_pictogram.Rd
  7. 70
      man/geom_pictogram.Rd
  8. 6
      man/geom_waffle.Rd
  9. 18
      man/scale_label_pictogram.Rd

3
DESCRIPTION

@ -47,6 +47,7 @@ Imports:
stats,
htmlwidgets,
DT,
rlang
rlang,
utils
RoxygenNote: 6.1.1
VignetteBuilder: knitr

3
NAMESPACE

@ -3,6 +3,7 @@
export(GeomPictogram)
export(GeomWaffle)
export(StatWaffle)
export(draw_key_pictogram)
export(fa_grep)
export(fa_list)
export(geom_pictogram)
@ -23,6 +24,7 @@ importFrom(extrafont,choose_font)
importFrom(extrafont,font_import)
importFrom(extrafont,ttf_import)
importFrom(ggplot2,aes)
importFrom(ggplot2,alpha)
importFrom(ggplot2,coord_equal)
importFrom(ggplot2,discrete_scale)
importFrom(ggplot2,element_blank)
@ -57,3 +59,4 @@ importFrom(grid,unit.pmin)
importFrom(gtable,is.gtable)
importFrom(rlang,is_missing)
importFrom(stats,setNames)
importFrom(utils,tail)

55
R/geom-pictogram.R

@ -14,11 +14,20 @@ picto_scale <- function(aesthetic, values = NULL, ...) {
discrete_scale(aesthetic, "manual", pal, ...)
}
#' Used with geom_pictogram() to map Font Awesome fonts to labels
#'
#' @param ... dots
#' @param values values
#' @param aesthetics aesthetics
#' @export
scale_label_pictogram <- function(..., values, aesthetics = "label") {
picto_scale(aesthetics, values, ...)
}
#' Legend builder for pictograms
#'
#' @param data,params,size legend key things
#' @keywords internal
#' @export
draw_key_pictogram <- function(data, params, size) {
@ -45,6 +54,51 @@ draw_key_pictogram <- function(data, params, size) {
)
}
#' Pictogram Geom
#'
#' There are two special/critical `aes()` mappings:
#' - `label` (so the geom knows which column to map the glyphs to)
#' - `values` (which column you're mapping the filling for the squares with)
#'
#' @md
#' @param mapping Set of aesthetic mappings created by `aes()` or
#' `aes_()`. If specified and `inherit.aes = TRUE` (the
#' default), it is combined with the default mapping at the top level of the
#' plot. You must supply `mapping` if there is no plot mapping.
#' @param n_rows how many rows should there be in the waffle chart? default is 10
#' @param flip If `TRUE`, flip x and y coords. n_rows then becomes n_cols.
#' Useful to achieve waffle column chart effect. Defaults is `FALSE`.
#' @param make_proportional compute proportions from the raw values? (i.e. each
#' value `n` will be replaced with `n`/`sum(n)`); default is `FALSE`.
#' @param data The data to be displayed in this layer. There are three
#' options:
#'
#' If `NULL`, the default, the data is inherited from the plot
#' data as specified in the call to `ggplot()`.
#'
#' A `data.frame`, or other object, will override the plot
#' data. All objects will be fortified to produce a data frame. See
#' `fortify()` for which variables will be created.
#'
#' A `function` will be called with a single argument,
#' the plot data. The return value must be a `data.frame.`, and
#' will be used as the layer data.
#' @param na.rm If `FALSE`, the default, missing values are removed with
#' a warning. If `TRUE`, missing values are silently removed.
#' @param show.legend logical. Should this layer be included in the legends?
#' `NA`, the default, includes if any aesthetics are mapped.
#' `FALSE` never includes, and `TRUE` always includes.
#' It can also be a named logical vector to finely select the aesthetics to
#' display.
#' @param inherit.aes If `FALSE`, overrides the default aesthetics,
#' rather than combining with them. This is most useful for helper functions
#' that define both data and aesthetics and shouldn't inherit behaviour from
#' the default plot specification, e.g. `borders()`.
#' @param ... other arguments passed on to `layer()`. These are
#' often aesthetics, used to set an aesthetic to a fixed value, like
#' `color = "red"` or `size = 3`. They may also be parameters
#' to the paired geom/stat.
#' @export
#' @export
geom_pictogram <- function(mapping = NULL, data = NULL,
n_rows = 10, make_proportional = FALSE, flip = FALSE,
@ -68,6 +122,7 @@ geom_pictogram <- function(mapping = NULL, data = NULL,
)
}
#' @rdname geom_pictogram
#' @export
GeomPictogram <- ggplot2::ggproto(
`_class` = "GeomPictogram",

5
R/geom-waffle.R

@ -23,7 +23,7 @@ draw_key_waffle <- function(data, params, size, ...) { # nocov start
#' Waffle (Square pie chart) Geom
#'
#' There are two special/critical `aes()` mappings:
#' - `fill` (so the geom knows which column to map the country names/abbrevs to)
#' - `fill` (so the geom knows which column to map the fills to)
#' - `values` (which column you're mapping the filling for the squares with)
#'
#' @md
@ -36,7 +36,7 @@ draw_key_waffle <- function(data, params, size, ...) { # nocov start
#' Useful to achieve waffle column chart effect. Defaults is `FALSE`.
#' @param make_proportional compute proportions from the raw values? (i.e. each
#' value `n` will be replaced with `n`/`sum(n)`); default is `FALSE`.
#' @param radius radius
#' @param radius radius for round squares
#' @param data The data to be displayed in this layer. There are three
#' options:
#'
@ -61,6 +61,7 @@ draw_key_waffle <- function(data, params, size, ...) { # nocov start
#' rather than combining with them. This is most useful for helper functions
#' that define both data and aesthetics and shouldn't inherit behaviour from
#' the default plot specification, e.g. `borders()`.
#' @param geom geom to use (default is "waffle")
#' @param ... other arguments passed on to `layer()`. These are
#' often aesthetics, used to set an aesthetic to a fixed value, like
#' `color = "red"` or `size = 3`. They may also be parameters

3
R/waffle-package.R

@ -19,10 +19,11 @@
#' @importFrom ggplot2 geom_point geom_text scale_color_manual guides theme labs
#' @importFrom ggplot2 scale_x_continuous scale_y_continuous coord_equal theme_bw
#' @importFrom ggplot2 aes guide_legend element_rect element_blank element_text layer
#' @importFrom ggplot2 discrete_scale
#' @importFrom ggplot2 discrete_scale alpha
#' @importFrom grid arrow unit grid.newpage grid.draw unit.c unit.pmax unit.pmin
#' @importFrom grid textGrob gpar grobTree roundrectGrob
#' @importFrom extrafont ttf_import font_import choose_font
#' @importFrom stats setNames
#' @importFrom utils tail
#' @importFrom rlang is_missing
NULL

15
man/draw_key_pictogram.Rd

@ -0,0 +1,15 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geom-pictogram.R
\name{draw_key_pictogram}
\alias{draw_key_pictogram}
\title{Legend builder for pictograms}
\usage{
draw_key_pictogram(data, params, size)
}
\arguments{
\item{data, params, size}{legend key things}
}
\description{
Legend builder for pictograms
}
\keyword{internal}

70
man/geom_pictogram.Rd

@ -0,0 +1,70 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geom-pictogram.R
\docType{data}
\name{geom_pictogram}
\alias{geom_pictogram}
\alias{GeomPictogram}
\title{Pictogram Geom}
\format{An object of class \code{GeomPictogram} (inherits from \code{GeomText}, \code{Geom}, \code{ggproto}, \code{gg}) of length 5.}
\usage{
geom_pictogram(mapping = NULL, data = NULL, n_rows = 10,
make_proportional = FALSE, flip = FALSE, ..., na.rm = FALSE,
show.legend = NA, inherit.aes = TRUE)
GeomPictogram
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{aes()} or
\code{aes_()}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
\item{data}{The data to be displayed in this layer. There are three
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{ggplot()}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{fortify()} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame.}, and
will be used as the layer data.}
\item{n_rows}{how many rows should there be in the waffle chart? default is 10}
\item{make_proportional}{compute proportions from the raw values? (i.e. each
value \code{n} will be replaced with \code{n}/\code{sum(n)}); default is \code{FALSE}.}
\item{flip}{If \code{TRUE}, flip x and y coords. n_rows then becomes n_cols.
Useful to achieve waffle column chart effect. Defaults is \code{FALSE}.}
\item{...}{other arguments passed on to \code{layer()}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{color = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}
\item{na.rm}{If \code{FALSE}, the default, missing values are removed with
a warning. If \code{TRUE}, missing values are silently removed.}
\item{show.legend}{logical. Should this layer be included in the legends?
\code{NA}, the default, includes if any aesthetics are mapped.
\code{FALSE} never includes, and \code{TRUE} always includes.
It can also be a named logical vector to finely select the aesthetics to
display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{borders()}.}
}
\description{
There are two special/critical \code{aes()} mappings:
\itemize{
\item \code{label} (so the geom knows which column to map the glyphs to)
\item \code{values} (which column you're mapping the filling for the squares with)
}
}
\keyword{datasets}

6
man/geom_waffle.Rd

@ -60,7 +60,7 @@ a warning. If \code{TRUE}, missing values are silently removed.}
It can also be a named logical vector to finely select the aesthetics to
display.}
\item{radius}{radius}
\item{radius}{radius for round squares}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
@ -71,11 +71,13 @@ the default plot specification, e.g. \code{borders()}.}
often aesthetics, used to set an aesthetic to a fixed value, like
\code{color = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}
\item{geom}{geom to use (default is "waffle")}
}
\description{
There are two special/critical \code{aes()} mappings:
\itemize{
\item \code{fill} (so the geom knows which column to map the country names/abbrevs to)
\item \code{fill} (so the geom knows which column to map the fills to)
\item \code{values} (which column you're mapping the filling for the squares with)
}
}

18
man/scale_label_pictogram.Rd

@ -0,0 +1,18 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geom-pictogram.R
\name{scale_label_pictogram}
\alias{scale_label_pictogram}
\title{Used with geom_pictogram() to map Font Awesome fonts to labels}
\usage{
scale_label_pictogram(..., values, aesthetics = "label")
}
\arguments{
\item{...}{dots}
\item{values}{values}
\item{aesthetics}{aesthetics}
}
\description{
Used with geom_pictogram() to map Font Awesome fonts to labels
}
Loading…
Cancel
Save