Passing a subset of data to ggplot2 layers.Source:
This is a convenience function to allow layer objects, such as geoms, to take
a subset of the data in the main
ggplot() call, without storing a
duplicate of the subset in the ggplot object.
expressionindicating which rows to keep.
charactercolumn name to exclude.
A function that takes a
data.frame as argument and returns a
subset of that
data.frame according to
ggsubset is a wrapper around
subset argument is set to
rowtest and the
-omit. Since the
data argument in the
layer() function can take a function with one argument, we can pass
the function returned from
ggsubset as that argument to subset the
data by rows.