This R package provides rudimentary methods for import/export of sensor data in formats typically used with LoggerNet software from Campbell Scientific.
A fixed time zone is used with data loggers quite often to minimize headache due to clock drift and its consequences. To make sure no unintended time zone conversion takes place, set some fixed time zone explicitly.
TOA5 (Table Oriented Ascii 5) format is the only one supported at the moment. To import data, use read.toa5 function.
library(csdf)
Sys.setenv(TZ='GMT')
fpath <- system.file("extdata", "Station_Daily.dat", package="csdf")
obj <- read.toa5(fpath)
This creates an S4 object of class csdf. No name sanitation takes place. Use backquotes for array related column names that contain parenthesis.
You can check common things with
summary(obj)
Data coverage is from 2014-04-11 to 2014-06-06 with temporal granularity of 1 days. There are no gaps in data coverage.
There are no issues with TIMESTAMP
There are no issues with RECORD
Data for TIMESTAMP
as well as other columns with names ending either on _TMx
or _TMn
are loaded as POSIXct.
One may directly access @data slot of csdf object. It contains the bulk data. Another useful slot is @variables that contains units and processing instructions used in CR Basic code.
plot(`AirT_Max` ~ time,
within(obj@data, {
time <- as.POSIXct(strftime(AirT_TMx, "%H:%M:%S"), format="%H:%M:%S")
}))
There are some convenience functions provided to cast (coerce) csdf object and to plot its content. One may use as(obj, "data.frame")
or equivalently as.data.frame(obj)
in place of obj@data
.
A quick plot using ggplot2 package can be produced with
plot(obj, ncol=2, meta=TRUE)
## Loading required namespace: reshape2
## Loading required namespace: gridExtra
## Loading required namespace: ggplot2
## Warning: Removed 1 rows containing missing values (geom_point).
One may save csdf objects directly to TOA5 format with write.toa5 function.
write.toa5(obj, "elsewhere.dat")