R/spectral_pca.R

Defines functions spectral_pca

Documented in spectral_pca

#' Principal Component Analysis of dewlap reflectance
#'
#' This function calculates the principal components of a reflectance dataset.
#'
#' @param specdata A data frame with reflectance in columns. The columns with reflectance information must have "wl" in their name, e.g. "wl500" for 500nm.
#' @return A \code{prcomp} object.
#' @author Raphael Scherrer
#' @export

spectral_pca <- function(specdata) {

  # Locate wavelength columns
  isWavelength <- grep("wl", colnames(specdata))

  # Calculate principal components
  dewlaPCA <- prcomp(specdata[,isWavelength], center = T, scale = T)

  return(dewlaPCA)

}
rscherrer/sagreicolor documentation built on March 24, 2019, 8:34 p.m.