chkinp: Check input data for PHABMetrics

Description Usage Arguments Details Value Examples

View source: R/chkinp.R

Description

Check input data for PHABMetrics

Usage

1
chkinp(data, purge = FALSE, msgs = FALSE)

Arguments

data

Input data

purge

If true, a data frame will be returned with problematic rows removed, see details.

msgs

logical, if FALSE a purged or non-purged data frame, if TRUE a two-element list with the data frame and concatenated list of messages, see the return value

Details

This function checks the following, relevant for the specified class of metrics:

algae: There are no conflicting values for every unique combination of id, LocationCode, AnalyteName, and VariableResult combination should have only one entry in VariableResult where AnalyteName is equal to "Microalgae Thickness", "Macrophyte Cover", "Macroalgae Cover, Attached", or "Macroalgae Cover, Unattached". This check is done for algae() metrics.

channelsinuosity: There are no conflicting values for every unique combination of id, LocationCode, AnalyteName, and Result combination should have only one entry in Result where AnalyteName is equal to "Slope", "Length, Segment", "Elevation Difference", "Bearing", "Proportion", or "Length, Reach".

Value

An error message is returned if the input data are not correctly formatted.

If msgs = FALSE (default), a data frame is returned that is either the same as the input if all checks have passed or a purged (purge = TRUE) or non-purged purge = FALSE) with or without offending rows removed. If msgs = TRUE, a two-element list is returned, where the first element data is the data frame that would be returned if msgs = FALSE and the second element is msgs with a concatenated character string of messages indicating if all checks have passed and if not, which issues were encountered. In the latter case, row numbers in the messages indicate which observations in the input data had issues.

Examples

1
2
3
4
5
6
7
8
9
dat <- phabformat(sampdat)

# get messages
datmsg <- chkinp(dat, msgs = TRUE)
datmsg$msgs

# get messages and purge
datprg <- chkinp(dat, msgs = TRUE, purge = TRUE)
dim(datprg$data)

SCCWRP/PHABMetrics documentation built on Oct. 28, 2021, 10:23 p.m.