filter_not_exist {admiral} | R Documentation |
Returns records that don't fit into existing by groups in a filtered source dataset
Description
Returns all records in the input dataset that belong to by groups that are not present in a source dataset, after the source dataset is optionally filtered. For example, this could be used to return ADSL records for subjects that didn't take certain concomitant medications during the course of the study (as per records in ADCM).
Usage
filter_not_exist(dataset, dataset_add, by_vars, filter_add = NULL)
Arguments
dataset |
Input dataset The variables specified by the |
dataset_add |
Source dataset The source dataset, which determines the by groups returned in the input dataset,
based on the groups that don't exist in this dataset after being subset by The variables specified in the |
by_vars |
Grouping variables Permitted Values: list of variables created by |
filter_add |
Filter for the source dataset The filter condition which will be used to subset the source dataset. Alternatively, if no filter condition is supplied, no subsetting of the source dataset will be performed. Default: |
Details
Returns the records in dataset
which don't match any existing by groups in
dataset_add
, after being filtered according to filter_add
. If all by
groups that exist in dataset
don't exist in dataset_add
, an empty dataset will
be returned.
Value
The records in the input dataset which are not contained within any existing by group in the filtered source dataset.
See Also
Utilities for Filtering Observations:
count_vals()
,
filter_exist()
,
filter_extreme()
,
filter_joined()
,
filter_relative()
,
max_cond()
,
min_cond()
Examples
# Get demographic information about subjects who didn't take vitamin supplements
# during the study
library(tibble)
adsl <- tribble(
~USUBJID, ~AGE, ~SEX,
"01-701-1015", 63, "F",
"01-701-1023", 64, "M",
"01-701-1034", 77, "F",
"01-701-1118", 52, "M"
)
adcm <- tribble(
~USUBJID, ~CMTRT, ~CMSTDTC,
"01-701-1015", "ASPIRIN", "2013-05-14",
"01-701-1023", "MYLANTA", "2014-01-04",
"01-701-1023", "CALCIUM", "2014-02-25",
"01-701-1034", "VITAMIN C", "2013-12-12",
"01-701-1034", "CALCIUM", "2013-03-27",
"01-701-1118", "MULTIVITAMIN", "2013-02-21"
)
filter_not_exist(
dataset = adsl,
dataset_add = adcm,
by_vars = exprs(USUBJID),
filter_add = str_detect(CMTRT, "VITAMIN")
)