Usage
nearPoints(df, coordinfo, xvar = NULL, yvar = NULL, panelvar1 = NULL, panelvar2 = NULL, threshold = 5, maxpoints = NULL, addDist = FALSE, allRows = FALSE)
Arguments
df
A data frame from which to select rows.
coordinfo
The data from a mouse event, such as input$plot_click
.
xvar
A string with the name of the variable on the x or y axis.
This must also be the name of a column in df
. If absent, then this
function will try to infer the variable from the brush (only works for
ggplot2).
yvar
A string with the name of the variable on the x or y axis.
This must also be the name of a column in df
. If absent, then this
function will try to infer the variable from the brush (only works for
ggplot2).
panelvar1
Each of these is a string with the name of a panel
variable. For example, if with ggplot2, you facet on a variable called
cyl
, then you can use "cyl"
here. However, specifying the
panel variable should not be necessary with ggplot2; Shiny should be able
to auto-detect the panel variable.
panelvar2
Each of these is a string with the name of a panel
variable. For example, if with ggplot2, you facet on a variable called
cyl
, then you can use "cyl"
here. However, specifying the
panel variable should not be necessary with ggplot2; Shiny should be able
to auto-detect the panel variable.
threshold
A maxmimum distance to the click point; rows in the data
frame where the distance to the click is less than threshold
will be
returned.
maxpoints
Maximum number of rows to return. If NULL (the default),
return all rows that are within the threshold distance.
addDist
If TRUE, add a column named dist_
that contains the
distance from the coordinate to the point, in pixels. When no mouse event
has yet occured, the value of dist_
will be NA
.
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
selected by the mouse event (TRUE
) or not (FALSE
).