combn_QC: Combine Quality Checking Results

View source: R/Data_handling.R

combn_QCR Documentation

Combine Quality Checking Results

Description

Combine quality checking results depending on whether they have a fixed or cumulative effect or any combination of these effects. It is also checked how should NAs be interpreted.

Usage

combn_QC(
  x,
  qc_names,
  name_out = "-",
  additive = NULL,
  na.as = NULL,
  additive_pattern = "interdep$|wresid$",
  na.as_0_pattern = "spikesLF$|fetch70$|man$",
  no_messages = FALSE
)

Arguments

x

A data frame with column names.

qc_names

A vector of names of data frame x columns to combine.

name_out

A character string providing varnames value of the output.

additive

NULL or a vector of logical values (TRUE or FALSE) determining additivity of each respective column of x given by qc_names. If NULL, automated recognition is used. Otherwise, values determine if the flags should be treated as additive (additive = TRUE) or with fixed effect (additive = FALSE). If only one value is provided, all columns are considered to be of the same type.

na.as

NULL or a vector of integer or NA values determining interpretation of missing flags in each respective column of x given by qc_names. If NULL, automated recognition is used. If only one value is provided, all columns are treated the same way.

additive_pattern

A character string. A regular expression grep pattern identifying qc_names of flags with additive effect.

na.as_0_pattern

A character string. A regular expression grep pattern identifying qc_names for which NA flags are interpreted as zeros.

no_messages

A logical value.

Details

The quality checking results to combine must be provided as columns of a data frame x, optionally with any number of further columns that will be ignored. Columns specified by qc_names will be further separated according to their additivity. For flags with fixed effect (additive = FALSE; the most typical type), maximum is taken over each row. For flags with additive effect (additive = TRUE), sum is taken over each row. In case both types of flags are present, results for both groups are summed together.

The most typical value of argument na.as is NA. NA value does not suggest any change in interpretation (value of variable corresponding to this flag will be removed within quality checking scheme). Exceptionally, value 0 can be used in case that the NA flag of the quality checking test/filter is an expected result and means that the half-hour was not checked by the given test/filter (e.g. despikeLF).

Value

An integer vector with attributes varnames and units is produced. varnames value is set by name_out argument. Default value of varnames and units is set to "-".

Automated recognition

Default values for additive and na.as arguments are FALSE and NA, respectively. In case that additive_pattern is found within qc_names (i.e. qc_names ending with "interdep" or "wresid" pattern), respective values of additive are changed to TRUE. This is because interdep and wresid (see extract_QC) quality control checks are defined as additive within the current quality control scheme. If na.as_0_pattern is detected within qc_names (i.e. qc_names ending with "spikesLF", "fetch70" or "man" pattern), respective values of na.as are changed to 0 (see despikeLF).

See Also

summary_QC.

Examples

set.seed(5)
aa <- data.frame(xx = sample(c(0:2, NA), 20, replace = TRUE))
aa$yy <- sample(c(0:2, NA), 20, replace = TRUE)
aa$add_F <- combn_QC(aa, qc_names = c("xx", "yy"), additive = FALSE,
name_out = "add_F")
aa$add_T <- combn_QC(aa, qc_names = c("xx", "yy"), additive = TRUE,
name_out = "add_T")
aa$add_F_na.as_0 <- combn_QC(aa, qc_names = c("xx", "yy"), additive = FALSE,
na.as = 0, name_out = "add_F_na.as_0")
aa$add_F_na.as_0part <- combn_QC(aa, qc_names = c("xx", "yy"),
additive = FALSE, na.as = c(0, NA), name_out = "add_F_na.as_0part")
aa$add_F_na.as_2 <- combn_QC(aa, qc_names = c("xx", "yy"), additive = FALSE,
na.as = 2, name_out = "add_F_na.as_2")
str(aa)
aa


lsigut/openeddy documentation built on Jan. 15, 2025, 8:14 a.m.