Learn R Programming

photobiology (version 0.10.6)

collect2mspct: Form a new collection

Description

Form a collection of spectra from separate objects in the parent frame of the call.

Usage

collect2mspct(
  .list = NULL,
  pattern = "*\\.spct$",
  collection.class = NULL,
  ...
)

Arguments

.list

list of R objects

pattern

character an optional regular expression, ignored if .list is not NULL.

collection.class

character vector

...

additional named arguments passed down to the collection constructor.

Value

By default a collection of spectra.

Details

This is a convenience function that simplifies the creation of collections from existing objects of class generic_spct or a derived class. A list of objects con be passed as argument, or a search pattern. If a list is passed, no search is done. If collection.class is NULL, then all objects of class generic_spct or of a class derived from it are added to the collection. If objects of only one derived class are to be collected this class or that of the matching collection should be passed as argument to collection.class. Objects of other R classes are silently discarded, which simplifies the specification of search patterns. By default, i.e., if collection.class is NULL, if all the objects collected belong to the same class then the corresponding collection class will be returned, otherwise a generic_mspct object with heterogeneous members will be returned. To force the return of a generic_mspct even when the collected spectra all belong to the same class, pass generic_mspct as argument to collection.class. If the argument to collection.class is a vector containing two of more class names, only the matching spectra will be collected, and a generic_mspct will be returned. The returned object is created with the constructor for the class, and validated.

See Also

Other experimental utility functions: drop_user_cols(), thin_wl(), uncollect2spct()

Examples

Run this code
# NOT RUN {
collect2mspct() # returns empty generic_mspct object

sun1.spct <- sun.spct
sun2.spct <- sun.spct
kk.spct <- 10:30 # ignored
collect2mspct()
collect2mspct(collection.class = "generic_mspct")

pet1.spct <- polyester.spct
collect2mspct()
collect2mspct(collection.class = "source_mspct")
collect2mspct(collection.class = "filter_mspct")
collect2mspct(collection.class = "response_mspct")

# }

Run the code above in your browser using DataLab