Learn R Programming

trajectories (version 0.2-1)

rTrack: Generate random Track, Tracks or TracksCollection objects

Description

Generate random Track, Tracks or TracksCollection objects

Usage

rTrack(n = 100, origin = c(0,0), start = as.POSIXct("1970-01-01"), ar = .8, 
	step = 60, sd0 = 1, bbox = bbox, transform = FALSE, nrandom = FALSE, ...)
rTracks(m = 20, start = as.POSIXct("1970-01-01"), delta = 7200, sd1 = 0, 
	origin = c(0,0), ...)
rTracksCollection(p = 10, sd2 = 0, ...)

Arguments

n

number of points per Track

origin

numeric, length two, indicating the origin of the Track

start

POSIXct, indicating the start time of the Track

ar

numeric vector, indicating the amound of correlation in the Track

step

numeric; time step(s) in seconds between Track fixes

sd0

standard deviation of the random steps in a Track

sd1

standard deviation of the consecutive Track origin values (using rnorm)

sd2

standard deviation of the consecutive Tracks origin values (using rnorm)

bbox

bbox object FIXME:fill in

transform

logical; FIXME:fill in

nrandom

logical; if TRUE, draw n from rpois(n)

...

rTrack: arguments passed on to arima.sim, rTracks: arguments passed on to rTrack; rTracksCollection: arguments passed on to rTracks

m

number of Track objects to simulate

delta

time difference between consecutive Track start times

p

number of IDs with Tracks to generate

Value

An object of class Track, Tracks or TracksCollection.

Details

ar is passed on to arima.sim as ar element, and may contain multiple AR coefficients. The generated track is a cumsum over the simulated AR values, for each dimension. In case it has length 1 and value 0, random walk is created using rnorm. If bbox is given, the generated track will be transformed to bbox. If transform is TRUE and no bbox is given, it transforms the track to a unit box. If nrandom is TRUE, it generates a random number using rpois with parameter n as the number of locations per track.

Examples

Run this code
# NOT RUN {
x = rTrack()
dim(x)
plot(x)
# x = rTracks(sd1 = 120)
# dim(x)
# plot(as(x, "SpatialLines"), col = 1:dim(x)[1], axes=TRUE)
# x = rTracksCollection() # star
# dim(x)
# plot(x)
x = rTracksCollection(sd2 = 200,p=4,m=10)
plot(x, col=1:dim(x)[1])
# }

Run the code above in your browser using DataLab