sliwinltr: Apply a Function on an Object of Class "ltraj", Using a...

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

View source: R/sliwinltr.r

Description

This function applies a function on an object of class "ltraj", using a sliding window.

Usage

1
2
3
sliwinltr(ltraj, fun, step, type = c("locs", "time"),
          units = c("sec", "min", "hour", "day"),
          plotit = TRUE, ...)

Arguments

ltraj

an object of class ltraj

fun

the function to be applied, implying at least one of the descriptive parameters in the object of class ltraj (see below)

step

the half-width of the sliding window. If type=="locs", it is a number of relocations. If type=="time" it is a number described by units

type

character string. If type == "locs", step describes a number of relocations: if type == "time", step describes a time lag.

units

if type == "time", the time units described by step. Ignored otherwise

plotit

logical. Whether the result should be plotted

...

additional arguments to be passed to the function rec

Details

An object of class ltraj is a list with one component per burst of relocations. The function fun is applied to each burst of relocations. This burst of relocations should be refered as x in fun. For example, to compute the mean of the distance between successive relocations, the function fun is equal to function(x) mean(x$dist).

Do not forget that some of the descriptive parameters in the object ltraj may contain missing values (see help(ltraj)). The function should therefore specify how to manage these missing values.

Value

If type=="locs", a list with one component per burst of relocation containing the smoothed values for each relocation.

If type=="locs", a list with one component per burst of relocation. Each component is a data frame containing the time and the corresponding smoothed values for each date.

Author(s)

Clement Calenge clement.calenge@ofb.gouv.fr

See Also

ltraj for additional information about objects of class ltraj

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
data(capreotf)

## computes the average speed of the roe deer in a moving window of width
## equal to 60 minutes
toto <- sliwinltr(capreotf, function(x) mean(x$dist/x$dt, na.rm = TRUE),
                  step = 30, type = "time", units = "min")

## zoom before the peak
head(toto[[1]])
plot(toto[[1]][1:538,], ty="l")

## End(Not run)

Example output

Loading required package: sp
Loading required package: ade4
Loading required package: adehabitatMA
Loading required package: CircStats
Loading required package: MASS
Loading required package: boot
                 date            y
1 2004-05-01 23:00:00 0.0002015101
2 2004-05-01 23:05:00 0.0002015101
3 2004-05-01 23:10:00 0.0002015101
4 2004-05-01 23:15:00 0.0001921761
5 2004-05-01 23:20:00 0.0002077311
6 2004-05-01 23:25:00 0.0002077311

adehabitatLT documentation built on Jan. 20, 2020, 1:13 a.m.