cutltraj: Split Trajectories into Several Bursts

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

View source: R/cutltraj.r

Description

The function cutltraj split the bursts in an object of class ltraj into several "sub-bursts", according to some specified criterion.
The function bindltraj binds the bursts an object of class ltraj with the same attributes "id" into one unique burst.

Usage

1
2
cutltraj(ltraj, criterion, value.NA = FALSE, nextr = TRUE, ...)
bindltraj(ltraj, ...)

Arguments

ltraj

an object of class ltraj

criterion

a character string giving any syntactically correct R logical expression implying the descriptive parameters in x

value.NA

logical. The value that should be used to replace the missing values.

nextr

logical. Whether the current "sub-burst" should stop after (nextr = TRUE) or before (nextr = FALSE) the first relocation matching criterion

...

additional arguments to be passed to other functions

Details

Splitting a trajectory may be of interest in many situations. For example, if it is known that two kinds of activities of the monitored animals correspond to different properties of, say, the distance between successive relocations, it may be of interest to split the trajectory according to the values of these distances.

Two options are available in cutltraj, depending on the value of nextr. If nextr = FALSE, any sequence of successive relocations that *do not* match the criterion is considered as a new burst. For example, if for a given burst, the criterion returns the vector (FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE), then the function cutltraj creates two new bursts of relocations, the first one containing the first 3 relocations and the second one the last 3 relocations.

If nextr = TRUE, any sequence of successive relocations that *do not* match the criterion, *as well as the first relocation that does match it after this sequence* is considered as a new burst. This option is available because many of the descriptive parameters associated to a given relocation in an object of class ltraj measure some specific feature concerning the position of the next relocation. For example, one may want to consider as a burst any sequence of relocations for which the time lag is below one hour (the criterion is "dt > 3600". The first relocation for which this criterion is TRUE belong to the burst, and it is the next one which is excluded from the burst. For example, if for a given burst, the criterion returns the vector (FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE), then the function cutltraj creates two new bursts of relocations, the first one containing the first 4 relocations and the second one the last 3 relocations.

Value

An object of class ltraj.

Author(s)

Clement Calenge clement.calenge@oncfs.gouv.fr

See Also

ltraj for additional information about objects of class ltraj (and especially concerning the names of the descriptive parameters that can be used in cutltraj). is.sd (especially the examples of this help page) for other examples of use of this function

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#######################################################
##
## GPS monitoring of one bear

data(bear)

## We want to study the trajectory of the day at the scale
## of the day. We define one trajectory per day. The trajectory should begin
## at 22H00
## The following function returns TRUE if the date is comprised between
## 21H00 and 22H00 (i.e. correspond to the relocation taken at 21H30)

foo <- function(date) {
     da <- as.POSIXlt(date, "GMT")
     ho <- da$hour + da$min/60
     return(ho>21&ho<22)
}

## We cut the trajectory into bursts after the relocation taken at 21H30:

bea1 <- cutltraj(bear, "foo(date)", nextr = TRUE)
bea1

## Remove the first and last burst:
bea2 <- bea1[-c(1,length(bea1))]


#######################################################
##
## Bind the trajectories

bea3 <- bindltraj(bea2)
bea3

adehabitat documentation built on Jan. 28, 2018, 5:02 p.m.