Extended data frame
exdf.Rd
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.
Arguments
- main_data
A data frame.
- units
A data frame with the same columns as
main_data
but with just one row, where each entry describes the units for the corresponding column ofmain_data
. Ifunits
isNULL
, it will be initialized withNA
for each column.- categories
A data frame with the same columns as
main_data
but with just one row, where each entry describes the category for the corresponding column ofmain_data
. Ifcategories
isNULL
, it will be initialized withNA
for each column.- ...
Any additional properties to include as entries in the resulting
exdf
object; these must be passed as named arguments.
Details
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:
Examples
# 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)))
#> A [NA] (NA) B [NA] (NA)
#> 1 3 4
#> 2 2 5
#> 3 7 1
#> 4 9 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')
)
#> A [Cat1] (m) B [Cat2] (s)
#> 1 3 4
#> 2 2 5
#> 3 7 1
#> 4 9 8