ggpack: Handling of argument passing to ggplots

Description Usage Arguments Value Note Author(s) Examples

Description

A helper function to wrap ggplot calls, allowing for passing of a shared list of arguments prefixed by an id string. For example, a call to a custom ggplot template may allow for arguments 'line.color' and 'bar.color' to specify the line and bar colors seperately. These arguments are parsed appropriately and passed to the appropriate sub-function.

Usage

1
ggpack(`_call` = NULL, ..., id = NULL, dots = NULL, null.empty = FALSE)

Arguments

_call

the function to call

...

additional arguments to use when calling the provided function

id

the prefix string to subset arguments by

dots

arguments to subset

null.empty

return NULL if no arguments are received

Value

a call to the specified function with arguments subset for only those which match the specified prefix

Note

Use 'substitute(...())' when collecting parent function ellipses args to pass into 'ggpack()' to accommodate unevaluated symbols.

Ellipses arguments and the arguments passed through the 'dots' args will overwrite previous arguments of the same name.

Author(s)

Doug Kelkhoff kelkhoff.douglas@gene.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(ggplot2)

# wrap layer calls in a ggpack to package them
ggpack(geom_bar(na.rm = TRUE))

# or more explicitly define layer properties
ggpack(geom_bar,              # layer function to bundle
  id = 'bar',                 # name of layer - used for filter listed args
  fill = 'red',               # ...'s before 'args' used as defaults
  dots = list(fill = 'blue'), # named 'args' param will overwrite prior ...'s
  fill = 'green')             # ...'s after 'args' will overwrite any others

lengning/gClinBiomarker documentation built on May 9, 2019, 2:55 p.m.