About

This R package provides rudimentary methods for import/export of sensor data in formats typically used with LoggerNet software from Campbell Scientific.

Importing data

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.

Table Oriented Ascii 5 (TOA5), CSIXML, and a subset for Table Oriented Binary 1 (TOB1) formats are supported at the moment. To import data, use read.toa5 function and alike.

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 for TIMESTAMP as well as other columns with names ending either on _TMx or _TMn are loaded as POSIXct.

Working with csdf object

Slots

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")
     }))

Convenience functions

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

grid::grid.draw( plot(obj, ncol=2, meta=TRUE) )

First, we call plot on csdf object, then grid.draw on gtable. We might be interested in internals of grob (gtable) object to assess number of panes when estimating device/image size to plot on. See ?csdf::`plot,csdf,missing-method` for details.

Saving csdf objects

One may save csdf objects directly to TOA5 format with write.toa5 function.

write.toa5(obj, "elsewhere.dat")


mlt/csdf documentation built on May 23, 2019, 4:06 a.m.