Learn R Programming

trajr (version 1.5.1)

TrajFromTrjPoints: Create a trajectory from a subset of another

Description

Creates a trajectory from a subset of the points in another trajectory, preserving metadata and all columns in the original trajectory.

Usage

TrajFromTrjPoints(trj, idx)

Value

A new trajectory which is the same as trj except with a subset of points.

Arguments

trj

Trajectory to extract points and metadata from.

idx

Indices of the points in trj to retain in the new trajectory.

Details

Note that removing points from a trajectory that does not contain a time column will change the timing of the points, and hence change velocity etc.

Examples

Run this code
if (FALSE) {
# Create a trajectory (trj2) by removing all zero-length
# segments from another trajectory (trj). Keep all points
# that are different from their preceding point, and also
# keep the start point
trj2 <- TrajFromTrjPoints(trj, c(1, which(Mod(trj$displacement) != 0)))
}

Run the code above in your browser using DataLab