readTDR: Read comma-delimited file with "TDR" data

Description Usage Arguments Details Value Note Author(s) Examples

Description

Read a delimited (*.csv) file containing time-depth recorder (TDR) data from various TDR models. Return a TDR or TDRspeed object. createTDR creates an object of one of these classes from other objects.

Usage

1
2
3
4
5
6
readTDR(file, dateCol=1, timeCol=2, depthCol=3, speed=FALSE,
        subsamp=5, concurrentCols=4:6,
        dtformat="%d/%m/%Y %H:%M:%S", tz="GMT", ...)
createTDR(time, depth,
          concurrentData=data.frame(matrix(ncol=0, nrow=length(time))),
          speed=FALSE, dtime, file)

Arguments

file

character: a string indicating the path to the file to read. This can also be a text-mode connection, as allowed in read.csv.

dateCol

integer: column number containing dates, and optionally, times.

timeCol

integer: column number with times.

depthCol

integer: column number containing depth readings.

speed

logical: whether speed is included in one of the columns of concurrentCols.

subsamp

numeric scalar: subsample rows in file with subsamp interval, in s.

concurrentCols

integer vector of column numbers to include as concurrent data collected.

dtformat

character: a string specifying the format in which the date and time columns, when pasted together, should be interpreted (see strptime).

tz

character: a string indicating the time zone assumed for the date and time readings.

...

Passed to read.csv

time

A POSIXct object with date and time readings for each reading.

depth

numeric vector with depth readings.

concurrentData

data.frame with additional, concurrent data collected.

dtime

numeric scalar: sampling interval used in seconds. If missing, it is calculated from the time argument.

Details

The input file is assumed to have a header row identifying each field, and all rows must be complete (i.e. have the same number of fields). Field names need not follow any convention. However, depth and speed are assumed to be in m, and m/s, respectively, for further analyses.

If speed is TRUE and concurrentCols contains a column named speed or velocity, then an object of class TDRspeed is created, where speed is considered to be the column matching this name.

Value

An object of class TDR or TDRspeed.

Note

Although TDR and TDRspeed classes check that time stamps are in increasing order, the integrity of the input must be thoroughly verified for common errors present in text output from TDR devices such as duplicate records, missing time stamps and non-numeric characters in numeric fields. These errors are much more efficiently dealt with outside of GNU R using tools like GNU awk or GNU sed, so diveMove does not currently attempt to fix these errors.

Author(s)

Sebastian P. Luque [email protected]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Do example to define object zz with location of dataset
utils::example("dives", package="diveMove",
               ask=FALSE, echo=FALSE)
srcfn <- basename(zz)
readTDR(zz, speed=TRUE, sep=";", na.strings="", as.is=TRUE)

## Or more pedestrian
tdrX <- read.csv(zz, sep=";", na.strings="", as.is=TRUE)
date.time <- paste(tdrX$date, tdrX$time)
tdr.time <- as.POSIXct(strptime(date.time, format="%d/%m/%Y %H:%M:%S"),
                       tz="GMT")
createTDR(tdr.time, tdrX$depth, concurrentData=data.frame(speed=tdrX$speed),
          file=srcfn, speed=TRUE)

diveMove documentation built on May 2, 2019, 4:47 p.m.