utilMWRinput {MassWateR}R Documentation

Utility function to import data as paths or data frames

Description

Utility function to import data as paths or data frames

Usage

utilMWRinput(
  res = NULL,
  acc = NULL,
  frecom = NULL,
  sit = NULL,
  wqx = NULL,
  fset = NULL,
  runchk = TRUE,
  warn = TRUE
)

Arguments

res

character string of path to the results file or data.frame for results returned by readMWRresults

acc

character string of path to the data quality objectives file for accuracy or data.frame returned by readMWRacc

frecom

character string of path to the data quality objectives file for frequency and completeness or data.frame returned by readMWRfrecom

sit

character string of path to the site metadata file or data.frame for site metadata returned by readMWRsites

wqx

character string of path to the wqx metadata file or data.frame for wqx metadata returned by readMWRwqx

fset

optional list of inputs with elements named res, acc, frecom, sit, or wqx, overrides the other arguments, see details

runchk

logical to run data checks with checkMWRresults, checkMWRacc, checkMWRfrecom, checkMWRsites, or checkMWRwqx, applies only if res, acc, frecom, sit, or wqx are file paths

warn

logical to return warnings to the console (default)

Details

The function is used internally by others to import data from paths to the relevant files or as data frames returned by readMWRresults, readMWRacc, readMWRfrecom, readMWRsites, or readMWRwqx. For the former, the full suite of data checks can be evaluated with runkchk = T (default) or suppressed with runchk = F.

The fset argument can used in place of the preceding arguments. The argument accepts a list with named elements as res, acc, frecom, sit, or wqx, where the elements are either character strings of the path or data frames to the corresponding inputs. Missing elements will be interpreted as NULL values. This argument is provided as convenience to apply a single list as input versus separate inputs for each argument.

Any of the arguments for the data files can be NULL, used as a convenience for downstream functions that do not require all.

Value

A five element list with the imported results, data quality objective files, site metadata, and wqx metadata, named "resdat", "accdat", "frecomdat", "sitdat", and "wqxdat", respectively.

Examples

##
# using file paths

# results path
respth <- system.file('extdata/ExampleResults.xlsx', package = 'MassWateR')

# accuracy path
accpth <- system.file('extdata/ExampleDQOAccuracy.xlsx', package = 'MassWateR')

# frequency and completeness path
frecompth <- system.file('extdata/ExampleDQOFrequencyCompleteness.xlsx', 
     package = 'MassWateR')

# site path
sitpth <- system.file('extdata/ExampleSites.xlsx', package = 'MassWateR')

# wqx path
wqxpth <- system.file('extdata/ExampleWQX.xlsx', package = 'MassWateR')

inp <- utilMWRinput(res = respth, acc = accpth, frecom = frecompth, sit = sitpth, wqx = wqxpth)
inp$resdat
inp$accdat
inp$frecomdat
inp$sitdat
inp$wqxdat

##
# using data frames

# results data
resdat <- readMWRresults(respth)

# accuracy data
accdat <- readMWRacc(accpth)

# frequency and completeness data
frecomdat <- readMWRfrecom(frecompth)

# site data
sitdat <- readMWRsites(sitpth)

# wqx data
wqxdat <- readMWRwqx(wqxpth)

inp <- utilMWRinput(res = resdat, acc = accdat, frecom = frecomdat, sit = sitdat, wqx = wqxpth)
inp$resdat
inp$accdat
inp$frecomdat
inp$sitdat
inp$wqxdat

##
# using fset as list input

# input with paths to files
fset <- list(
  res = respth, 
  acc = accpth, 
  frecom = frecompth,
  sit = sitpth, 
  wqx = wqxpth
)
utilMWRinput(fset = fset)

[Package MassWateR version 2.1.4 Index]