lassoPoints: Find rows of data within a closed lasso

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/lassoPoints.R

Description

Identify the rows of a data.frame lying within a closed lasso polygon, analogous to brushedPoints.

Usage

1
lassoPoints(df, lasso)

Arguments

df

A data.frame from which to select rows.

lasso

A list containing data from a lasso.

Details

This function uses in.out from the mgcv package to identify points within a polygon. This involves a boundary crossing algorithm that may not be robust in the presence of complex polygons with intersecting edges.

Value

A subset of rows from df with coordinates lying within lasso.

Author(s)

Aaron Lun

See Also

brushedPoints

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
lasso <- list(coord=rbind(c(0, 0), c(0.5, 0), c(0, 0.5), c(0, 0)),
    closed=TRUE, mapping=list(x="X", y="Y"))
values <- data.frame(X=runif(100), Y=runif(100),
    row.names=sprintf("VALUE_%i", seq_len(100)))
lassoPoints(values, lasso)

# With faceting information:
lasso <- list(coord=rbind(c(0, 0), c(0.5, 0), c(0, 0.5), c(0, 0)),
    panelvar1="A", panelvar2="B", closed=TRUE,
    mapping=list(x="X", y="Y",
    panelvar1="FacetRow", panelvar2="FacetColumn"))
values <- data.frame(X=runif(100), Y=runif(100),
    FacetRow=sample(LETTERS[1:2], 100, replace=TRUE),
    FacetColumn=sample(LETTERS[1:4], 100, replace=TRUE),
    row.names=sprintf("VALUE_%i", seq_len(100)))
lassoPoints(values, lasso)

iSEE documentation built on Feb. 3, 2021, 2:01 a.m.