Learn R Programming

MotilityLab (version 0.2-5)

tracks: Tracks Objects

Description

The function tracks is used to create tracks objects. as.tracks coerces its argument to a tracks object, and is.tracks tests for tracks objects. c can be used to combine (concatenate) tracks objects.

Usage

as.tracks(x, ...)
"as.tracks"(x, ...)
is.tracks(x)
"c"(...)
tracks(...)

Arguments

x
an object to be coerced or tested.
...
for tracks, numeric matrices or objects that can be coerced to numeric matrices. Each matrix contains the data of one track. The first column is the time, and the remaining columns define a spatial position. Every given matrix has to contain the same number of columns, and at least two columns are necessary.

For c, tracks objects to be combined.

For as.tracks, further arguments passed to methods (currently not used).

Details

Tracks objects are lists of matrices. Each matrix contains at least two columns; the first column is time, and the remaining columns are a spatial coordinate. The following naming conventions are used (and enforced by tracks): The time column has the name `t`, and spatial coordinate columns have names `x`,`y`,`z` if there are three or less coordinates, and `x1`,...,`xk` if there are $k \ge 4$ coordinates. All tracks in an object must have the same number of dimensions. The positions in a track are expected to be sorted by time (and the constructor tracks enforces this).

Examples

Run this code
## A single 1D track
x <- tracks( matrix(c(0, 8,  
10, 9, 
20, 7, 
30, 7,
40, 6, 
50, 5), ncol=2, byrow=TRUE ) )

## Three 3D tracks
x2 <- tracks( rbind(
 c(0,5,0), c(1,5,3), c(2,1,3), c(3,5,6) ),
 rbind( c(0,1,1),c(1,1,4),c(2,5,4),c(3,5,1),c(4,-3,1) ),
 rbind( c(0,7,0),c(1,7,2),c(2,7,4),c(3,7,7) ) )

Run the code above in your browser using DataLab