Learn R Programming

playwith (version 0.8-56)

playSelectData: Let playwith user select data points

Description

Part of the playwith Application Programming Interface.

Usage

playSelectData(playState, prompt = "Click or drag to select data points.")

Arguments

playState
a playState object representing the plot, window and device.
prompt
text to display in the prompt.

Value

  • playSelectData returns NULL if the user cancelled (e.g. by right-clicking). Otherwise a list with:
  • spacecharacter, specifies the plot space in which data points were selected. See the space argument to playDo.
  • whichindices of the data points selected. This relies on the data being guessed correctly from the plot call, unless data.points was specified explicitly. Note that for lattice plots, these are indices into the packet/panel data, not indices into the original data set, so not the same as subscripts.
  • x, ynative coordinates of the selected data points.
  • is.clicklogical, whether it was a click (otherwise a drag).
  • posposition of click relative to the closest point, as in the pos argument to text. If is.click is false, this is NULL.
  • as well as all the other elements returned by playRectInput.

Details

playSelectData is similar to identify. The user is prompted to click or drag to select data points. If a click, the nearest point is selected, if it is within 18 points. If it is a drag, all points within the rectangular region are selected. Note that data points can be selected from one panel of a multi-panel lattice plot without specifying the panel beforehand.

See Also

playRectInput, playwith.API

Examples

Run this code
if (interactive()) {

library(lattice)
playwith(xyplot(Sepal.Width ~ Petal.Width | Species, data = iris))
playSelectData(playDevCur())

}

Run the code above in your browser using DataLab