Function checks the validity of each characteristic-method speciation combination in the dataframe. When clean = "suspect_only", rows with Suspect characteristic-method speciation combinations are removed. Default is clean = "suspect_only". When flaggedonly = TRUE, dataframe is filtered to show only rows with "Suspect" or "NonStandardized" characteristic-method speciation combinations. Default is flaggedonly = FALSE.
Usage
TADA_FlagSpeciation(
.data,
clean = c("suspect_only", "nonstandardized_only", "both", "none"),
flaggedonly = FALSE
)
Arguments
- .data
TADA dataframe
- clean
Character argument with options "suspect_only", "nonstandardized_only", "both", or "none." The default is clean = "suspect_only" which removes rows of data flagged as having "Suspect" characteristic-method speciation combinations. When clean = "nonstandardized_only", the function removes rows of data flagged as having "NonStandardized" characteristic-method speciation combinations. When clean = "both", the function removes rows of data flagged as either "Suspect" or "NonStandardized". And when clean = "none", the function does not remove any "Suspect" or "NonStandardized" rows of data.
- flaggedonly
Boolean argument; filters to show only the "Suspect" characteristic-method speciation combinations from the dataframe when flaggedonly = TRUE. Default is flaggedonly = FALSE.
Value
This function adds TADA.MethodSpeciation.Flag to the dataframe. This column flags each TADA.CharacteristicName and MethodSpeciationName combination in your dataframe as either "NonStandardized", "Suspect", "Pass", or "Not Reviewed". When clean = "none" and flaggedonly = TRUE, the dataframe is filtered to show only the "Suspect" and "NonStandardized data; the column TADA.MethodSpeciation.Flag is still appended. When clean = "suspect_only" and flaggedonly = FALSE, "Suspect" rows are removed from the dataframe, but "NonStandardized" rows are retained. When clean = "nonstandardized_only" and flaggedonly = FALSE, "NonStandardized" rows are removed, but "Suspect" rows are retained. The default is clean = "suspect_only" and flaggedonly = FALSE.
Details
The “Not Reviewed” value within "TADA.ResultAboveUpperThreshold.Flag" means that the EPA WQX team has not yet reviewed the combinations (see https://cdx.epa.gov/wqx/download/DomainValues/QAQCCharacteristicValidation.CSV). The WQX team plans to review and update these new combinations quarterly.
Examples
# Load example dataset:
data(Data_Nutrients_UT)
# Remove data with Suspect characteristic-method speciation combinations from dataframe,
# but retain "NonStandardized" combinations flagged in new column 'TADA.MethodSpeciation.Flag':
SuspectSpeciation_clean <- TADA_FlagSpeciation(Data_Nutrients_UT)
# Remove data with "NonStandardized" characteristic-method speciation combinations
# from dataframe but retain Suspect combinations flagged in new column 'TADA.MethodSpeciation.Flag':
NonstandardSpeciation_clean <- TADA_FlagSpeciation(Data_Nutrients_UT, clean = "nonstandardized_only")
# Remove both "Suspect" and "NonStandardized" characteristic-method speciation combinations
# from dataframe:
Speciation_clean <- TADA_FlagSpeciation(Data_Nutrients_UT, clean = "both")
# Flag, but do not remove, data with "Suspect" or "NonStandardized" characteristic-method speciation
# combinations in new column titled "TADA.MethodSpeciation.Flag":
SuspectSpeciation_flags <- TADA_FlagSpeciation(Data_Nutrients_UT, clean = "none")
#> [1] "Rows with Suspect speciations have been flagged but retained. Review these rows before proceeding and/or set clean = 'suspect_only' or 'both'."
# Show only Suspect characteristic-method speciation combinations:
SuspectSpeciation_flaggedonly <- TADA_FlagSpeciation(Data_Nutrients_UT, clean = "nonstandardized_only", flaggedonly = TRUE)
#> [1] "This dataframe is empty because either we did not find any Suspect/NonStandardized characteristic-method speciation combinations or they were all filtered out"
# Show only "NonStandardized" characteristic-method speciation combinations:
NonstandardSpeciation_flaggedonly <- TADA_FlagSpeciation(Data_Nutrients_UT, clean = "suspect_only", flaggedonly = TRUE)
#> [1] "This dataframe is empty because either we did not find any Suspect/NonStandardized characteristic-method speciation combinations or they were all filtered out"