subset.ggghost {ggghost}R Documentation

Extract a subset of a ggghost object

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

## 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

## 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))

[Package ggghost version 0.2.1 Index]