Description Arguments Examples
Converting Spectra
object to data.frame is straightforward
while the conversion in the opposite direction requires a set of attributes
to be present in the source data.frame object.
These attributes are generally created during the conversion of a
Spectra
object into data.frame, they can
also be manually set if they are non-existant (see the example below).
from |
The input object |
to |
Name of the class of output object |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #Convert a Spectra object to data.frame
sp <- spc.example_spectra()
df <- as(sp, "data.frame")
class(df); dim(df)
attributes(df)
#Convert the data.frame back to Spectra
sp2 <- as(df, "Spectra")
#Convert a bare data.frame to Spectra with minimal attributes
df2 <- data.frame(ch1=c(1,2,3,4), ch2=c(5,6,7,8), TIME=Sys.time()+1:4, LAT=1:4, LON=5:8)
attr(df2, "Units") <- "m-1"
attr(df2, "Wavelengths") <- c(500, 600)
attr(df2, "ShortName") <- "abs"
as(df2, "Spectra")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.