Filter a Data Frame Based on Marginal Criteria
Source:R/format_template.R
filter_on_marginal_of_spanning_var.Rd
This function filters rows in a data frame based on marginal criteria. It applies filtering conditions to a subset of keys and their corresponding values, and excludes rows where other keys match the given totals.
Examples
if (FALSE) { # \dontrun{
df <- data.frame(
col1 = c("A", "B", "TOTAL"),
col2 = c("X", "TOTAL", "Y"),
col3 = c("Z", "Z", "Z")
)
criteria <- list(col1 = "TOTAL", col2 = "TOTAL", col3 = "TOTAL")
filter_on_marginal_of_spanning_var(df, criteria, subset_keys = c("col1", "col2"))
# Filters the data frame based on the criteria and subset_keys.
} # }