Learn R Programming

DescTools (version 0.99.6)

AreaIdent: Identify Points in Plot Defined by an Upper-Left and a Bottom-Right Click

Description

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

Usage

AreaIdent(formula, data, subset)

Arguments

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.

Value

  • Index vector with the points lying within the selected area. The coordinates are returned as text in the attribute "cond".

See Also

identify, locator

Examples

Run this code
# run the example via copy and paste

plot(temperature ~ delivery_min, data=d.pizza)
idx <- AreaIdent(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

Run the code above in your browser using DataLab