mspct2mat: Convert a collection of spectra into a matrix


Convert an object of class generic_mspct or a derived class into an R matrix with wavelengths saved as an attribute and spectral data in rows or columns.


mspct2mat(x,, byrow = attr(x, "mspct.byrow"), ...)



generic_mspct object.

character The name of the variable containing the spectral data.


logical. If FALSE (the default) the matrix is filled with the spectra stored by columns, otherwise the matrix is filled by rows.


currently ignored.


This conversion preserves the spectral data but discards almost all the metadata contained in the spectral objects. In other words a matrix created with this function cannot be used to recreate the original object unless the same metadata is explicitly supplied when converting the matrix into new collection of spectra.


Only collections of spectra containing spectra with exactly the same w.length values can by converted. If needed, the spectra can be re-expressed before attempting the conversion to a matrix.

Questions? Problems? Suggestions? or email at

All documentation is copyright its authors; we didn't write any of that.