rbindspct {photobiology} | R Documentation |
Row-bind spectra
Description
A wrapper on dplyr::rbind_fill
that preserves class and other
attributes of spectral objects.
Usage
rbindspct(
l,
use.names = TRUE,
fill = TRUE,
idfactor = TRUE,
attrs.source = NULL,
attrs.simplify = FALSE
)
Arguments
l |
A |
use.names |
logical If |
fill |
logical If |
idfactor |
logical or character Generates an index column of
|
attrs.source |
integer Index into the members of the list from which
attributes should be copied. If |
attrs.simplify |
logical Flag indicating that when all values of an attribute are equal for all members, the named list will be replaced by a single copy of the value. |
Details
Each item of l
should be a spectrum, including NULL
(skipped) or an empty object (0 rows). rbindspc
is most useful when
there are a variable number of (potentially many) objects to stack.
rbindspct
always returns at least a generic_spct
as long as
all elements in l are spectra.
Value
An spectral object of a type common to all bound items containing a concatenation of all the items passed in. If the argument 'idfactor' is TRUE, then a factor 'spct.idx' will be added to the returned spectral object.
Note
Note that any additional 'user added' attributes that might exist on
individual items of the input list will not be preserved in the result.
The attributes used by the photobiology
package are preserved, and
if they are not consistent across the bound spectral objects, a warning is
issued.
dplyr::rbind_fill
is called internally and the result returned is
the highest class in the inheritance hierarchy which is common to all
elements in the list. If not all members of the list belong to one of the
_spct
classes, an error is triggered. The function sets all data in
source_spct
and response_spct
objects supplied as arguments
into energy-based quantities, and all data in filter_spct
objects
into transmittance before the row binding is done. If any member spectrum
is tagged, it is untagged before row binding.
Examples
# default, adds factor 'spct.idx' with letters as levels
spct <- rbindspct(list(sun.spct, sun.spct))
spct
class(spct)
# adds factor 'spct.idx' with letters as levels
spct <- rbindspct(list(sun.spct, sun.spct), idfactor = TRUE)
head(spct)
class(spct)
# adds factor 'spct.idx' with the names given to the spectra in the list
# supplied as formal argument 'l' as levels
spct <- rbindspct(list(one = sun.spct, two = sun.spct), idfactor = TRUE)
head(spct)
class(spct)
# adds factor 'ID' with the names given to the spectra in the list
# supplied as formal argument 'l' as levels
spct <- rbindspct(list(one = sun.spct, two = sun.spct),
idfactor = "ID")
head(spct)
class(spct)