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)
Run the code above in your browser using DataLab