View source: R/spct.metadata.r
spct_metadata | R Documentation |
Return metadata attributes from a single spectrum or a collection of spectra
as a data.frame
. A wrapper on add_attr2tb
providing an
alternative order of formal parameters and constrained functionality.
spct_metadata(
x,
col.names = NULL,
idx = "spct.idx",
na.rm = is.null(col.names),
unnest = TRUE
)
x |
generic_mspct or generic_spct Any collection of spectra or spectrum. |
col.names |
named character vector Name(s) of column(s) to create. |
idx |
character Name of the column with the names of the members of the collection of spectra. |
na.rm |
logical Flag controlling deletion of columns containing only NA values. |
unnest |
logical Flag controlling if metadata attributes that are lists of values should be returned in a list column or in separate columns. |
Each attribute is by default copied to a column in a tibble
or a data.frame
. If the argument for tb
is NULL
, as by
default, a new tibble
will be created. If an existing
data.frame
or tibble
is passed as argument, new columns are
added to it. However, the number of rows in the argument passed to
tb
must match the number of spectra in the argument passed to
mspct
. Only in the case of methods add_attr2tb()
and
spct_metadata()
if the argument to col.names
is a named
vector, the names of members are used as names for the columns created.
This permits setting any valid name for the new columns. If the members of
the vector passed to col.names
have no names, then the value is
interpreted as the name of the attributes to add, and also used as name for
the new column.
Valid values accepted as argument to col.names
are NULL
, or a
vector containing one or more of the following character
strings:
"lon"
, "lat"
, "address"
, "geocode"
,
"where.measured"
, "when.measured"
, "what.measured"
,
"how.measured"
, "comment"
, "normalised"
,
"normalized"
, "scaled"
, "bswf.used"
,
"instr.desc"
, "instr.settings"
, solute.properties
,
"filter.properties"
, "Tfr.type"
, "Rfr.type"
,
"time.unit"
.
A data.frame
or a tibble
With the metadata attributes
in separate new variables.
The order of the first two arguments is reversed in
add_attr2tb()
, when_measured2tb()
, what_measured2tb()
,
etc., compared to attribute query functions, such as spct_metadata
,
when_measured()
, what_measured()
, how_measured()
, etc.
This is to allow the use of add_attr2tb()
in 'pipes' to add metadata
to summaries computed at earlier steps in the pipe.
add_attr2tb
for more details.
Other measurement metadata functions:
add_attr2tb()
,
getFilterProperties()
,
getHowMeasured()
,
getInstrDesc()
,
getInstrSettings()
,
getSoluteProperties()
,
getWhatMeasured()
,
getWhenMeasured()
,
getWhereMeasured()
,
get_attributes()
,
isValidInstrDesc()
,
isValidInstrSettings()
,
select_spct_attributes()
,
setFilterProperties()
,
setHowMeasured()
,
setInstrDesc()
,
setInstrSettings()
,
setSoluteProperties()
,
setWhatMeasured()
,
setWhenMeasured()
,
setWhereMeasured()
,
spct_attr2tb()
,
subset_attributes()
,
trimInstrDesc()
,
trimInstrSettings()
# collection of spectra
spct_metadata(sun_evening.mspct)
spct_metadata(sun_evening.mspct, na.rm = FALSE)
spct_metadata(sun_evening.mspct,
col.names = "geocode",
unnest = FALSE)
spct_metadata(sun_evening.mspct,
col.names = c(when.measured = "time", "what.measured"))
# multiple spectra in long form
spct_metadata(sun_evening.spct,
col.names = c("geocode", "when.measured"))
# single spectrum
spct_metadata(sun.spct,
col.names = c("geocode", "when.measured"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.