exdf | R Documentation |
An "extended data frame" (exdf
) is an object similar to a data frame,
but which also contains information about the units and categories of each
column.
exdf(
main_data = data.frame(),
units = NULL,
categories = NULL,
...
)
main_data |
A data frame. |
units |
A data frame with the same columns as |
categories |
A data frame with the same columns as |
... |
Any additional properties to include as entries in the resulting |
The exdf
class was originally created as a way to represent the
contents of a Licor Excel file in an R structure. In Licor Excel files, each
column has a name, units, and a category; for example, the column for values
of net assimilation rate is called A
, has units of micromol / m^2
/ s
, and is categorized as a GasEx
variable.
From a technical point of view, an exdf
object is simply a list with
three required elements: main_data
, units
, and
categories
. Each of these should be a data frame with the same column
names, as described above. It is also possible for an exdf
object to
have additional entries such as a filename
that stores the name of the
file that was used to create the exdf
.
Several S3 methods have been defined for exdf
objects, following the
general guidance from
Advanced R on S3 classes:
is.exdf
as.data.frame.exdf
print.exdf
str.exdf
length.exdf
dim.exdf
dimnames.exdf
[.exdf
[<-.exdf
rbind.exdf
cbind.exdf
split.exdf
by.exdf
Note that the column names of main_data
, units
, and
categories
must be unique; the make.unique
function can
be useful for ensuring this.
An exdf
object as described above.
# Example 1: Creating a simple exdf object with two columns (`A` and `B`) and
# default values for its units and categories. There are four values of each
# variable.
exdf(data.frame(A = c(3, 2, 7, 9), B = c(4, 5, 1, 8)))
# Example 2: Creating a simple exdf object with two columns (`A` and `B`) that
# have units of `m` and `s`, respectively, and categories of `Cat1` and `Cat2`,
# respectively. There are four values of each variable.
exdf(
data.frame(A = c(3, 2, 7, 9), B = c(4, 5, 1, 8)),
data.frame(A = 'm', B = 's'),
data.frame(A = 'Cat1', B = 'Cat2')
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.