Standardizes a water quality data set using substitute_variables and substitute_units so that all remaining values have the recognised codes and variables in codes and the standard units. If column Code is present then a Variable column is created using lookup_variables. The standardize_wqdata function is called by clean_wqdata prior to cleaning.

standardize_wqdata(
  x,
  strict = TRUE,
  messages = getOption("wqbc.messages", default = TRUE)
)

Arguments

x

A data.frame to standardize.

strict

A flag indicating whether to require all words in a recognised variable name to be present in x (strict = TRUE) or only the first one (strict = FALSE) [Soft-deprecated] .

messages

A flag indicating whether to print messages.

See also

Examples

standardize_wqdata(wqbc::dummy, messages = TRUE)
#> Standardizing water quality data...
#> Deleted 2 rows with missing values in Value.
#> Substituted 'DISSOLVED ALUMINUM' with 'Aluminum Dissolved'.
#> Failed to substitute 'Aluminium Dissolved' and 'Kryptonite'.
#> Deleted 10 rows with missing values in Variable.
#> Substituted 'MG/L' with 'mg/L', 'PH UNITS' with 'pH' and 'uG/L' with 'ug/L'.
#> Failed to substitute 'midichlorians'.
#> Deleted 1 row with missing values in Units.
#> Standardized water quality data.
#> # A tibble: 6 × 4
#>   Date       Variable           Value Units
#>   <date>     <chr>              <dbl> <chr>
#> 1 2000-01-02 Aluminum Dissolved   1   mg/L 
#> 2 2000-01-02 Aluminum Dissolved   2   mg/L 
#> 3 1977-05-25 Zinc Total           1   ug/L 
#> 4 2000-01-01 pH                   8   pH   
#> 5 2000-01-01 pH                   9.5 pH   
#> 6 1978-12-01 pH                   7   pH