Learn R Programming

ggghost (version 0.2.3)

subset.ggghost: 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 ggghost
subset(x, ...)

Value

Another ggghost object containing only the calls selected.

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.

Examples

Run this code
## 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))

Run the code above in your browser using DataLab