Description Details Methods Author(s) References See Also Examples
Melts the spectra data of a Spectra object and returns it as wide format.
This function is very useful when wanting to plot spectra using the lattice or ggplot2 packages.
x=Spectra
melt_spectra(obj, ...)
obj | A Spectra object |
|
... | Ignored | |
x=SpectraDataFrame
melt_spectra(obj, attr=NULL, ...)
obj | A SpectraDataFrame object |
|
attr | Character, the name of an attribute in the object data to split the spectra against. | |
... | Ignored | |
Pierre Roudier pierre.roudier@gmail.com
Hadley Wickham (2011). The Split-Apply-Combine Strategy for Data Analysis. Journal of Statistical Software, 40(1), 1-29. URL http://www.jstatsoft.org/v40/i01/.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Loading example data
data(australia)
spectra(australia) <- sr_no ~ ... ~ 350:2500
# Simple melt
r <- melt_spectra(australia)
head(r)
## Not run:
# Melt against some factor (or continuous data), and plot
# using ggplot2
# Create some factor
australia$fact <- sample(LETTERS[1:3], size = nrow(australia), replace = TRUE) # Generate some kind of factor
r <- melt_spectra(australia, attr = 'fact')
# Create plot
library(ggplot2)
p <- ggplot(r) + geom_line(aes(x=wl, y=nir, group=id, colour=fact)) + theme_bw()
print(p)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.