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.