Learn R Programming

DescTools (version 0.99.19)

IdentifyA: Identify Points in Plot Lying Within a Rectangle or Polygon

Description

Find all the points lying either in a rectangle area, spanned by an upper left point and a bottom-right point clicked by the user or in a polygon area defined by the user.

Usage

IdentifyA(x, ...)
"IdentifyA" (formula, data, subset, poly = FALSE, ...) "IdentifyA" (x, y = NULL, poly = FALSE, ...)

Arguments

x, y
x and y values of the points used to create the plot.
formula
a formula, such as y ~ x specifying x and y values. Here the formula must be entered that was used to create the scatterplot.

data
a data frame (or list) from which the variables in formula should be taken.

subset
an optional vector specifying a subset of observations to be used.

poly
logical. Defines if a polygon or a rectangle should be used to select the points. Default is rectangle. If a polygon should be used, set this argument to TRUE and select all desired points. The polygon will be closed automatically when finished.
...
Other arguments to be passed to IdentifyA.

Value

The coordinates are returned as text in the attribute "cond".

See Also

identify, locator

Examples

Run this code
## Not run: 
# # run the example via copy and paste
# 
# plot(temperature ~ delivery_min, data=d.pizza)
# idx <- IdentifyA(temperature ~ delivery_min, data=d.pizza)
# 
# # you selected the following points
# d.pizza[idx,]
# points(temperature ~ delivery_min, data = d.pizza[idx,], col="green")
# 
# # use the attr("cond") for subsets in code
# attr(idx, "cond")
# 
# # create a group variable for the found points
# d.pizza$grp <- seq(nrow(d.pizza)) %in% idx
# 
# # try the polygon option
# idx <- IdentifyA(temperature ~ delivery_min, data=d.pizza, poly=TRUE)
# points(temperature ~ delivery_min, data = d.pizza[idx,], col="red")
# ## End(Not run)

Run the code above in your browser using DataLab