DescTools (version 0.99.8.1)

identify.formula: Identify points in a plot using a formula.

Description

The function identify reads the position of the graphics pointer when the (first) mouse button is pressed. It then searches the coordinates given in x and y for the point closest to the pointer. If this point is close enough to the pointer, its index will be returned as part of the value of the call.

Usage

## S3 method for class 'formula':
identify(x, data = NULL, ...)

Arguments

x
A formula of the form y ~ x.
data
The data frame from which the formula should be evaluated.
...
Other arguments to be passed to identify.

Value

  • If pos is FALSE, an integer vector containing the indices of the identified points, in the order they were identified. If pos is TRUE, a list containing a component ind, indicating which points were identified and a component pos, indicating where the labels were placed relative to the identified points (1=below, 2=left, 3=above, 4=right and 0=no offset, used if atpen = TRUE).

Details

This function is meant to make it easier to call identify after plot has been called using a formula and the data argument. A two dimensional plot must be active and the vectors in x and data frame in data must correspond to the x- and y-axes and the data of the plot.

See Also

identify, locator, text http://www.rforge.net/NCStats/files/

Examples

Run this code
## Copy and try in an interactive R session

df <- data.frame(x=runif(10), y=runif(10), grp=factor(rep(c("Yes","No"), each=5)))
plot(y ~ x, data=df)
identify(y ~ x, data=df)

Run the code above in your browser using DataCamp Workspace