Skip to contents

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.

Usage

filter_on_marginal_of_spanning_var(data, criteria, subset_keys)

Arguments

data

A data frame to be filtered.

criteria

A named list or vector where the names are column names, and the values are the totals or values to be used in filtering.

subset_keys

A character vector of keys (column names) to be included in the filter criteria.

Value

A filtered data frame where rows meet the specified criteria and exclude the subset keys.

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.
} # }