tabMWRwqx {MassWateR} | R Documentation |
Create and save tables in a single workbook for WQX upload
Description
Create and save tables in a single workbook for WQX upload
Usage
tabMWRwqx(
res = NULL,
acc = NULL,
sit = NULL,
wqx = NULL,
fset = NULL,
output_dir,
output_file = NULL,
warn = TRUE,
runchk = TRUE
)
Arguments
res |
character string of path to the results file or |
acc |
character string of path to the data quality objectives file for accuracy or |
sit |
character string of path to the site metadata file or |
wqx |
character string of path to the wqx metadata file or |
fset |
optional list of inputs with elements named |
output_dir |
character string of the output directory for the results |
output_file |
optional character string for the file name, must include .xlsx suffix |
warn |
logical to return warnings to the console (default) |
runchk |
logical to run data checks with |
Details
This function will export a single Excel workbook with three sheets, named "Project", "Locations", and "Results". The output is populated with as much content as possible based on information in the input files. The remainder of the information not included in the output will need to be manually entered before uploading the data to WQX. All required columns are present, but individual rows will need to be verified for completeness. It is the responsibility of the user to verify this information is complete and correct before uploading the data.
The workflow for using this function is to import the required data (results, data quality objectives file for accuracy, site metadata, and wqx metadata) and to fix any errors noted on import prior to creating the output. The function can be used with inputs as paths to the relevant files or as data frames returned by readMWRresults
, readMWRacc
, readMWRsites
, and readMWRwqx
. For the former, the full suite of data checks can be evaluated with runkchk = T
(default) or suppressed with runchk = F
, as explained in the relevant help files. In the latter case, downstream analyses may not work if data are formatted incorrectly. For convenience, a named list with the input arguments as paths or data frames can be passed to the fset
argument instead. See the help file for utilMWRinput
.
The name of the output file can also be changed using the output_file
argument, the default being wqxtab.xlsx
. Warnings can also be turned off or on (default) using the warn
argument. This returns any warnings when data are imported and only applies if the file inputs are paths.
Value
An Excel workbook named wqxtab.xlsx
(or name passed to output_file
) will be saved in the directory specified by output_dir
. The workbook will include three sheets names "Projects", "Locations", and "Results".
Examples
# results data path
respth <- system.file('extdata/ExampleResults.xlsx', package = 'MassWateR')
# dqo accuracy data path
accpth <- system.file('extdata/ExampleDQOAccuracy.xlsx', package = 'MassWateR')
# site data path
sitpth <- system.file('extdata/ExampleSites.xlsx', package = 'MassWateR')
# wqx data path
wqxpth <- system.file('extdata/ExampleWQX.xlsx', package = 'MassWateR')
# results data
resdat <- readMWRresults(respth)
# accuracy data
accdat <- readMWRacc(accpth)
# site data
sitdat <- readMWRsites(sitpth)
# wqx data
wqxdat <- readMWRwqx(wqxpth)
# create workbook
tabMWRwqx(res = resdat, acc = accdat, sit = sitdat, wqx = wqxdat, output_dir = tempdir())