Skip to contents

[Deprecated] This function is deprecated and it's likely going to be dropped in the next release cycle.

Filter a single data frame or a list of data frames with custom predicates assembled from the function parameters.

Usage

threshold_filter(x, threshold, cols_to_compare = "Value", comparators = ">")

Arguments

x

A data frame or a list of data frames

threshold

A numeric/integer vector or a named list of numeric/integer vectors

cols_to_compare

A character vector or a named list of character vectors

comparators

A character vector or a named list of character vectors. Must be one of the allowed values between c("<", ">", "==", "!=", ">=", "<=")

Value

A data frame or a list of data frames

Examples

if (FALSE) {
example_df <- tibble::tibble(
    a = c(20, 30, 40),
    b = c(40, 50, 60),
    c = c("a", "b", "c"),
    d = c(3L, 4L, 5L)
)
example_list <- list(
    first = example_df,
    second = example_df,
    third = example_df
)

filtered <- threshold_filter(example_list,
    threshold = list(
        first = c(20, 60),
        third = c(25)
    ),
    cols_to_compare = list(
        first = c("a", "b"),
        third = c("a")
    ),
    comparators = list(
        first = c(">", "<"),
        third = c(">=")
    )
)
filtered
}