R/spectrace_to_wide.R

Defines functions spectrace_to_wide

Documented in spectrace_to_wide

#' Spectral data to wide format
#'
#' Reshapes spectral data from long to wide format, with one column per wavelength.
#'
#' @param lightData Data frame with light data. Must contain one column with the
#'    wavelengths named "wl" and one column with the values per wavelength named
#'    "val".
#'
#' @return Reshaped data.
#' @export
#'
#' @examples
spectrace_to_wide <- function(lightData) {
  lightData %>%
    dplyr::mutate(wl = paste0(wl, "nm")) %>%
    tidyr::pivot_wider(names_from = wl, values_from = val)
}
steffenhartmeyer/spectrace documentation built on Dec. 4, 2024, 4:13 p.m.