setNA: Place Missing Values in Objects of Class 'ltraj'

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

View source: R/setNA.r

Description

This function places missing values in an (approximately) regular trajectory, when a relocation should have been collected, but is actually missing.

Usage

1
2
setNA(ltraj, date.ref, dt, tol = dt/10,
      units = c("sec", "min", "hour", "day"), ...)

Arguments

ltraj

an object of class ltraj

date.ref

an object of class POSIXt (see below)

dt

the time lag between relocations

tol

the tolerance, which measures the imprecision in the timing of data collection (see below)

units

a character string indicating the time units for dt and tol

...

additional arguments to be passed to the function rec

Details

During the field study, the collection of the relocations of a trajectory may sometimes fail, which results into missing values. The class ltraj deal with these missing values, so that it is recommended to store the missing values in the data *before* the creation of the object of class ltraj. For example, GPS collars often fail to locate the animal, so that the GPS data imported within R contain missing values. It is recommended to *not remove* these missing values.

However, sometimes, the data come without any information concerning the location of these missing values. If the trajectory is approximately regular (i.e. approximately constant time lag), it is possible to determine where these missing values should occur in the object of class ltraj. This is the role of the function setNA.

The relocations in the object of class ltraj may not have been collected at exactly identical time lag (e.g. a relocation is collected at 17H57 instead of 18H00). The function setNA requires that the imprecision in the timing is at most equal to tol. Because of this imprecision, it is necessary to pass a reference date as argument to the function setNA. This reference date is used to determine at which time the missing values should be placed.

The reference date is chosen so that the rest of the division of (date.relocations - reference.date) by the time lag dt is equal to zero. For example, if it is known that one of the relocations of the trajectory has been collected on January 16th 1996 at 18H00, and if the theoretical time lag between two relocations is of one hour, the date of reference could be (for example) the August 1st 2007 at 05H00, because these two dates are separated by an exact number of hours (i.e. an exact number of dt). Therefore, any date fulfilling this condition could be passed as reference date. Alternatively, the August 1st 2007 at 05H30 is an uncorrect reference date, because the number of hours separating these two dates is not an integer.

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. sett0 (especially the examples of this help page) and is.regular for additional information about 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
data(porpoise)
foc <- porpoise[1]

## the list foc does not contain any missing value:
foc
plotNAltraj(foc)

## we remove the second to tenth relocation
foc[[1]] <- foc[[1]][-c(2:10),]
foc <- rec(foc)

## The missing values are not visible:
foc
plotNAltraj(foc)

## The porpoise is located once a day.
## We use the first relocation as the reference date
foc2 <- setNA(foc, foc[[1]]$date[1], 24*3600)

## Missing values are now present
foc2
plotNAltraj(foc2)

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