spectra | R Documentation |
spectra
"manually" creates a spectra object
spectra(value, bands, names, meta = NULL, ...)
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 |
spectra object
This function resorts to an ugly hack to deal with metadata assignment. Need to think a little harder to find a solution.
Jose Eduardo Meireles
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.