validate_stic_data {STICr}R Documentation

validate_stic_data.R

Description

This function takes a data frame with field observations of wet/dry status and SpC and generates both a confusion matrix for the wet/dry observations and a scatterplot comparing estimated SpC from the STICs to field-measured values.

Usage

validate_stic_data(
  stic_data,
  field_observations,
  max_time_diff,
  join_cols,
  get_SpC,
  get_QAQC
)

Arguments

stic_data

classified STIC data frame with the variable names of that produced by classify_wetdry. At a minimum, there must be datetime, condUncal, and wetdry columns, and an SpC column if get_SpC = T.

field_observations

The input data frame of field observations must include a datetime column (in POSIXct format), as well as a column labeled wetdry consisting of the character strings “wet” or “dry” (as in the processed STIC data itself). Additionally, if field data on SpC was collected (e.g., with a sonde), this should be included as a third column called SpC, and units should be in µS/cm.

max_time_diff

Maximum allowed time difference (in minutes) between field observation and STIC reading to be counted as a match.

join_cols

A named vector of columns that need to be matched between stic_data and field_observations in addition to datetime. This could include, for instance, a column specifying the site at which the observation was collected. Should be in the format of c("col_name_in_stic_data" = "col_name_in_field_observations") and can have as many columns as desired. If there are no additional columns to be matched, set to NULL.

get_SpC

Logical flag whether to get STIC data for SpC (T) or not (T). You must have an SpC column in stic_data and field_observations if this is used.

get_QAQC

Logical flag whether to get the STIC QAQC data (T) or not (T). You must have an QAQC column in both stic_data if this is used.

Value

The field_observations data frame with new columns indicating the closest-in-time STIC wetdry classification (wetdry_STIC), SpC measurement (SpC_STIC; only if get_SpC = T), and time difference between the field observation and STIC reading (timediff_min).

Examples

stic_validation <-
  validate_stic_data(
    stic_data = classified_df,
    field_observations = field_obs,
    max_time_diff = 30,
    join_cols = NULL,
    get_SpC = TRUE,
    get_QAQC = FALSE
  )

[Package STICr version 1.1 Index]