Learn R Programming

dunlin (version 0.1.12)

log_filter: Filter Data with Log

Description

Filter Data with Log

Usage

log_filter(data, condition, ...)

# S3 method for data.frame log_filter(data, condition, suffix = NULL, ...)

# S3 method for list log_filter( data, condition, table, by = c("USUBJID", "STUDYID"), suffix = NULL, verbose = FALSE, mode = ifelse(table == "adsl", "all", "unique"), ... )

Value

a data.frame or list of data.frame filtered for the provided conditions.

Arguments

data

(data.frame) input data to subset, or named (list of data.frame).

condition

(call) of subset condition. Must evaluate as logical.

...

further arguments to be passed to or from other methods.

suffix

(string) optional argument describing the filter.

table

(string) table name.

by

(character) variable names shared by table and other datasets for filtering when mode == "all".

verbose

(flag) whether to print a report about the filtering.

mode

(string) one of all or unique whether the other tables should be filtered based on the rows retained in table. Default value is "all" is table == "adsl" and "unique" otherwise.

Details

log_filter will filter the data.frame /named list of data.frame according to the condition. All the variables in condition must exist in the data (as variables) or in the parent frame(e.g., in global environment). For a named list of data.frame, set mode = "all"`` to filter other tables by keys retained in table (using by), or mode = "unique"` to leave other tables unchanged.

Examples

Run this code
data <- iris
attr(data$Sepal.Length, "label") <- "cm"
log_filter(data, Sepal.Length >= 7)

log_filter(list(iris = iris), Sepal.Length >= 7, "iris", character(0))

Run the code above in your browser using DataLab