summary_QC: Quality Control Summary

View source: R/Data_handling.R

summary_QCR Documentation

Quality Control Summary

Description

summary_QC is a function that summarizes quality checking results in a form of table or plot.

Usage

summary_QC(
  x,
  qc_names,
  cumul = FALSE,
  plot = FALSE,
  perc = TRUE,
  flux = NULL,
  na.as = NULL,
  na.as_0_pattern = "spikesLF$|fetch70$|man$",
  additive = NULL,
  additive_pattern = "interdep$|wresid$",
  no_messages = FALSE
)

Arguments

x

A data frame with column names.

qc_names

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

cumul

A logical value that determines if cumulative (cumul = TRUE) or individual (cumul = FALSE) effects of quality control flags should be shown.

plot

A logical value. If TRUE, the results are represented as a ggplot object. If FALSE, they are represented as a table.

perc

A logical value. If TRUE, the results are reported in percentages. If FALSE, counts are used instead.

flux

A character string. Used only if plot = TRUE. Includes the flux name in the plot title to emphasize the relevance of displayed quality control filters.

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.

na.as_0_pattern

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

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.

additive_pattern

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

no_messages

A logical value.

Details

summary_QC loads a data frame x, extracts quality control (QC) columns from it based on qc_names and creates a table (plot = FALSE) or a plot (plot = TRUE) for these columns. Results are displayed as percentages (perc = TRUE) or counts (perc = FALSE) for given flag and QC filter.

cumul = TRUE specifies that cumulative effect of gradually applied QC filters on resulting flags is considered. Note that for cumul = TRUE the results do depend on the order of qc_names. additive is considered only if cumul = TRUE, otherwise skipped.

For a detailed description of automated recognition see combn_QC.

Value

A table or a ggplot object depending on the plot argument value. If length(qc_names) == 0, NULL is returned instead.

See Also

combn_QC, ggplot.

Examples

set.seed(6)
aa <- as.data.frame(replicate(
6, sample(c(0:2, NA), 20, replace = TRUE, prob = c(0.6, 0.25, 0.1, 0.05))))
names(aa) <- letters[1:6]

summary_QC(aa, letters[1:6])
summary_QC(aa, letters[1:6], na.as = c(NA, 0, NA, NA, NA, NA))
summary_QC(aa, letters[1:6], cumul = TRUE, additive = TRUE)
summary_QC(aa, letters[1:6], cumul = TRUE, additive = FALSE)
is_add <- c(FALSE, FALSE, TRUE, FALSE, FALSE, FALSE)
summary_QC(aa, letters[1:6], cumul = TRUE, additive = is_add)

library(ggplot2)
(xx <- summary_QC(aa, letters[1:6], cumul = TRUE, plot = TRUE,
flux = "CO2 flux"))
xx + theme(text = element_text(size = 20))


lsigut/openeddy documentation built on Aug. 5, 2023, 12:25 a.m.