is.sd: Handling of Trajectories of the Same Duration

Description Usage Arguments Value Author(s) See Also Examples

View source: R/is.sd.r

Description

is.sd tests whether the bursts of relocations in an object of class ltraj contain the same number of relocations, and cover the same duration ("sd" = "same duration").
sd2df gets one of the descriptive parameters of a regular "sd" trajectory (e.g. "dt", "dist", etc.) and returns a data frame with one relocation per row, and one burst per column.

Usage

1
2

Arguments

ltraj

an object of class ltraj

what

a character string indicating the descriptive parameter of the trajectory to be exported

Value

is.sd returns a logical value.
sd2df returns a data frame with one column per burst of relocations, and one row per relocation.

Author(s)

Clement Calenge clement.calenge@oncfs.gouv.fr

See Also

set.limits for additional information about "sd" regular trajectories

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
34
35
36
37
38
39
40
41
42
## Takes the example from the help page of cutltraj (bear):
data(bear)

## We want to study the trajectory of the animal 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 and FALSE otherwise (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.1&ho<21.9)
}

## 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))]

## Is the resulting object "sd" ?
is.sd(bea2)

## Converts to data frame:
df <- sd2df(bea2, "dist")

## Plots the average distance per hour
meandi <- apply(df[-nrow(df),], 1, mean, na.rm = TRUE)
sedi <- apply(df[-nrow(df),], 1, sd, na.rm = TRUE) / sqrt(ncol(df))
plot(seq(0, 23.5, length = 47),
     meandi,
     ty = "b", pch = 16, xlab = "Hours (time 0 = 22H00)",
     ylab="Average distance covered by the bear in 30 mins",
     ylim=c(0, 500))
lines(seq(0, 23.5, length = 47),
      meandi+sedi, col="grey")
lines(seq(0, 23.5, length = 47),
      meandi-sedi, col="grey")

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