ptlocator: Data point locator

View source: R/ptlocator.R

ptlocatorR Documentation

Data point locator

Description

the ptlocator function allows for the selection of data points in an open graphical device via the locator function. Closest data points to the selected positions are determined via Euclidean distance following a scaling of x and y axes in order to give them equal weighting and remove the influence of differing units or ranges. Colored points are filled in for the data point that has the lowest distance to the clicked location, and the result gives the vector positions of the closest x, y data points.

Usage

ptlocator(n = NULL, x, y, col = rgb(1, 0, 0, 0.5), pch = 20, ...)

Arguments

n

Number of points to select

x

Vector of x-axis values for the plotted data

y

Vector of y-axis values for the plotted data

col

Colors to use for plotting closest data points

pch

pch values to use for plotting closest data points

...

additional parameters for plotting closest data points

Value

A vector of point indices

Examples

if(interactive()){
set.seed(1)
n <- 200
x <- sort(runif(n, min = 0, max = 10*pi))
y <- sin(x) + rnorm(n, sd = 0.2)

# Select 10 points at maxima and minima 
plot(x, y)
(pos <- ptlocator(10, x, y))
}



marchtaylor/sinkr documentation built on July 4, 2022, 5:48 p.m.