readTDR {diveMove} | R Documentation |
Read a comma 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.
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(), speed=FALSE, dtime, file)
file |
A string indicating the path to the file to read. |
dateCol |
Column number containing dates, and optionally, times. |
timeCol |
Column number with times. |
depthCol |
Column number containing depth readings. |
speed |
For readTDR : Logical indicating whether speed is
included in one of the columns of concurrentCols. |
subsamp |
Subsample rows in file with subsamp
interval, in s. |
concurrentCols |
Column numbers to include as concurrent data collected. |
dtformat |
A string, specifying the format in which the date and
time columns, when pasted together, should be interpreted (see
strptime ). |
tz |
A string indicating the time zone assumed for the date and time readings. |
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 |
Sampling interval used in seconds. If missing, it is
calculated from the time argument. |
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.
An object of class TDR
or TDRspeed
.
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.
Sebastian P. Luque spluque@gmail.com
readTDR(system.file(file.path("data", "dives.csv"), package="diveMove"), speed=TRUE) ## Or more pedestrian tdrX <- read.csv(system.file(file.path("data", "dives.csv"), package="diveMove"), 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="dives.csv", speed=TRUE)