This function returns rows from a data frame which are under a brush used
A data frame from which to select rows.
The data from a brush, such as
A string with the name of the variable on the x or y axis.
This must also be the name of a column in
Each of these is a string with the name of a panel
variable. For example, if with ggplot2, you facet on a variable called
It is also possible for this function to return all rows from the input data
frame, but with an additional column
selected_, which indicates which
rows of the input data frame are selected by the brush (
FALSE for not-selected). This is enabled by setting
arguments specify which columns in the data correspond to the x variable, y
variable, and panel variables of the plot. For example, if your plot is
plot(x=cars$speed, y=cars$dist), and your brush is named
"cars_brush", then you would use
brushedPoints(cars, input$cars_brush, "speed", "dist").
For plots created with ggplot2, it should not be necessary to specify the
column names; that information will already be contained in the brush,
provided that variables are in the original data, and not computed. For
ggplot(cars, aes(x=speed, y=dist)) + geom_point(), you
brushedPoints(cars, input$cars_brush). If, however, you use
a computed column, like
ggplot(cars, aes(x=speed/2, y=dist)) + geom_point(), then it will not be able to automatically extract column names
and filter on them. If you want to use this function to filter data, it is
recommended that you not use computed columns; instead, modify the data
first, and then make the plot with "raw" columns in the modified data.
If a specified x or y column is a factor, then it will be coerced to an integer vector. If it is a character vector, then it will be coerced to a factor and then integer vector. This means that the brush will be considered to cover a given character/factor value when it covers the center value.
If the brush is operating in just the x or y directions (e.g., with
brushOpts(direction = "x"), then this function will filter out points
using just the x or y variable, whichever is appropriate.
plotOutput() for example usage.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.