subset.ggghost: Extract a subset of a ggghost object

Description Usage Arguments Value Examples

Description

Alternative to subtracting calls using '-.gg', this method allows one to select the desired components of the available calls and have those evaluated.

Usage

1
2
## S3 method for class 'ggghost'
subset(x, ...)

Arguments

x

A ggghost object to subset

...

A logical expression indicating which elements to select. Typically a vector of list numbers, but potentially a vector of logicals or logical expressions.

Value

Another ggghost object containing only the calls selected.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## create a ggghost object
tmpdata <- data.frame(x = 1:100, y = rnorm(100))

z %g<% ggplot(tmpdata, aes(x,y))
z <- z + geom_point(col = "steelblue")
z <- z + theme_bw()
z <- z + labs(title = "My cool ggplot")
z <- z + labs(x = "x axis", y = "y axis")
z <- z + geom_smooth()

## remove the labels and theme
subset(z, c(1,2,6))
## or
subset(z, c(TRUE,TRUE,FALSE,FALSE,FALSE,TRUE))

ggghost documentation built on May 1, 2019, 9:25 p.m.