View source: R/Data_handling.R
correct | R Documentation |
Substitute given characters or strings by their alternatives.
correct(x, attr = c("names", "units"), ...)
x |
A character vector. |
attr |
A character string identifying an attribute type a character
vector |
... |
Further arguments to be passed to the internal
|
The function is intended to simplify the use of variable names and units
within the typical processing workflow employing
openeddy
.
If attr = "names"
, correction is meant to arrive to syntactically
valid names with a higher level of control. This assumes that the original
names were preserved during data loading (e.g. by using check.names =
FALSE
in read_eddy
or read.table
). Specifically,
literal strings are renamed as:
"(z-d)/L"
by
"zeta"
"qc_Tau"
by "qc_Tau_SSITC"
"qc_H"
by "qc_H_SSITC"
"qc_LE"
by
"qc_LE_SSITC"
"qc_co2_flux"
by "qc_NEE_SSITC"
and specified patterns or characters withing strings are substituted using regular expression patterns:
"co2_flux"
by "NEE"
"*"
by "star"
"%"
by "perc"
"-"
and "/"
by "_"
.
After the substitutions
make.names(names = x, ...)
is executed.
If attr = "units"
, round and square brackets are substituted by an
empty string.
A corrected character vector.
make.names
.
correct(c("co2_flux", "qc_co2_flux", "(z-d)/L", "x_70%", "*[-(z-d)/L"))
correct(c("qc_co2_flux", "qc_NEE_SSITC"), unique = TRUE)
correct(c("[m]", "(s)", "kg"), attr = "units")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.