pca <- prcomp (~ spc, data = flu$., center = FALSE)
scores <- decomposition (flu, pca$x, label.wavelength = "PC",
label.spc = "score / a.u.")
loadings <- decomposition (flu, t(pca$rotation), scores = FALSE,
label.spc = "loading I / a.u.")
plotspc (loadings, stacked = TRUE, col = matlab.palette(6))
plotc (scores, groups = .wavelength,col = matlab.palette(6), type = "b")
pca$sdev
## everything besides the first component is just noise
## Reconstructing the data using only the first PC results in a noise
## filtered data set.
flu.filtered <- scores[,,1] %*% loadings[1,,]
## example 2
pca <- prcomp (~ spc, data = chondro$., tol = 0.1)
scores <- decomposition (chondro, pca$x, label.wavelength = "PC",
label.spc = "score / a.u.")
plotmap (scores[,,1])
Run the code above in your browser using DataLab