spectra {spectrolab} | R Documentation |
Spectra object constructor
Description
spectra
"manually" creates a spectra object
Usage
spectra(value, bands, names, meta = NULL, ...)
Arguments
value |
N by M numeric matrix. N samples in rows and M bands in columns |
bands |
band names in vector of length M |
names |
sample names in vector of length N |
meta |
spectra metadata. defaults to NULL. Must be either of length or nrow equals to the number of samples (nrow(value) or length(names)) |
... |
additional arguments to metadata creation. not implemented yet |
Value
spectra object
Note
This function resorts to an ugly hack to deal with metadata assignment. Need to think a little harder to find a solution.
Author(s)
Jose Eduardo Meireles
Examples
library(spectrolab)
# 1. Create a value matrix.
# In this case, by removing the first column that holds the species name
rf = spec_matrix_example[ , -1]
# (2) Create a vector with band labels that match
# the value matrix columns.
wl = colnames(rf)
# (3) Create a vector with sample labels that match
# the value matrix rows.
# In this case, use the first colum of spec_matrix_example
sn = spec_matrix_example[ , 1]
# Finally, construct the spectra object using the `spectra` constructor
spec = spectra(value = rf, bands = wl, names = sn)
[Package spectrolab version 0.0.19 Index]