as.rspec: Convert data to an rspec object

View source: R/as.rspec.R

as.rspecR Documentation

Convert data to an rspec object

Description

Converts data frames or matrices containing spectral data to rspec object

Usage

as.rspec(
  object,
  whichwl = NULL,
  interp = TRUE,
  lim = NULL,
  exceed.range = TRUE
)

is.rspec(object)

Arguments

object

(required) a data frame or matrix containing spectra to process.

whichwl

a numeric or character vector specifying which column contains wavelengths. If NULL (default), function searches for column containing equally spaced numbers and sets it as wavelengths "wl". If no wavelengths are found or whichwl is not given, returns arbitrary index values.

interp

whether to interpolate wavelengths in 1-nm bins (defaults to TRUE). It is rarely recommended to turn off this option, as uninterpolated spectra are incompatible with some downstream analyses, including notably colour vision models.

lim

vector specifying wavelength range to interpolate over (e.g. c(300, 700)).

exceed.range

logical. Should data be interpolated to the limits specified by lim if lim exceeds the range of the actual data? Useful, and relatively safe, when the data range falls slightly within lim (e.g. 300.1 - 699 nm), but will produce spurious results if lim far exceeds the range of input data. Defaults to TRUE.

Value

an object of class rspec for use in further pavo functions

a logical value indicating whether the object is of class rspec

Author(s)

Chad Eliason cme16@zips.uakron.edu

Examples


# Generate some fake reflectance data
fakedat <- data.frame(wl = 300:700, refl1 = rnorm(401), refl2 = rnorm(401))
head(fakedat)

# Determine if is rspec object
is.rspec(fakedat)

# Convert to rspec object
fakedat2 <- as.rspec(fakedat)
is.rspec(fakedat2)
head(fakedat2)

pavo documentation built on Sept. 24, 2023, 5:06 p.m.