brushed: Returns a data frame with points marked which are under a...

Description Usage Arguments Value Examples

View source: R/brush.R

Description

This function returns all rows from the input data frame with an additional column selected_, which indicates which rows of the input data frame are selected by the brush (TRUE for selected, FALSE for not-selected).The xvar, yvar arguments specify which columns in the data correspond to the x variable, y variable of the plot. Based on ggbrush by Joe Cheng.

Usage

1
brushed(plotExpr, allRows = FALSE)

Arguments

plotExpr

A ggplot object.

allRows

If FALSE (the default) return a data frame containing the selected rows. If TRUE, the input data frame will have a new column, selected_, which indicates whether the row was inside the brush (TRUE) or outside the brush (FALSE).

Value

A data frame

Examples

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

# Example dataset
dates = as.POSIXct(seq(from = ymd("2013-01-01"),
 to = ymd("2014-01-01"), by = 3 * 3600))
Data = data.frame(dates, value = sin(decimal_date(dates)/0.01) +
 rnorm(length(dates)))

# Select points
p = qplot(data = Data, dates, value)
brushed(p)

D-ESC/dataQC documentation built on Nov. 26, 2021, 3:21 p.m.