getExpResid: getExpResid

View source: R/ExpResidFxn.R

getExpResidR Documentation

getExpResid

Description

Computes residuals from a linear regression using the first order decay function as defined in Helms et al. 2008, Limnol. Oceanogr., 53(3), 955-969. Function assumes that the column names of the absorbance data file being used are formatted as grnumbers.

Usage

getExpResid(wavelength, rangeReg, rangeGap, dataAbs, waveCol,
  colSubsetString, dataSummary, grnum, plotResid = FALSE)

Arguments

wavelength

absorbance numeric wavelength

rangeReg

numeric string with absorbance wavelength range to be considered for computing spectral slope

rangeGap

numeric string with the absorbance wavelength range for which decay function should be applied

dataAbs

dataframe with absorbance spectra results, one column per sample, and one column containing the wavelength at which an absorbance measurment is made.

waveCol

character column name to define the wavelengths for which absorbance was measured

colSubsetString

unique characters to identify which columns contain absorbance data. The default is "gr" to comply with the common naming from the CA WSC. The sample names must begin with 1-n characters for the function to work.

dataSummary

dataframe with summary absorbance and fluoresence data. This function adds columns to the end of this dataframe as additional summary data.

grnum

character column name that defines the column with sample names in the dataSummary dataframe.

plotResid

boolean variable indicating wether plots of the absorbance coefficients with the regression result should be plotted.

Value

dataframe with the added spectral slope for each sample and plots with the absorbance spectra for rangeReg showing the model constructed using the spectral slope (red); and the absorbance data where black = the data in rangeReg that is not in rangeGap and blue = the data from rangeGap.

Examples

wavelength <- 267
rangeReg <- c(240,340)
rangeGap <- c(255,300)
dataAbs <- dfabs
waveCol <- "wavelengths"
colSubsetString <- "gr"
dataSummary <- dfsummary
grnum <- "GRnumber"
testdfOpt <- getExpResid(wavelength,rangeReg,rangeGap,dataAbs,waveCol,
                    colSubsetString,dataSummary,grnum)

USGS-R/USGSHydroOpt documentation built on Oct. 18, 2022, 9:50 a.m.