Learn R Programming

EDCimport (version 0.6.0)

select_distinct: Select only distinct columns

Description

Select all columns that has only one level for a given grouping scope. Useful when dealing with mixed datasets containing both long data and repeated short data.

Usage

select_distinct(df, .by)

Value

df with less columns

Arguments

df

a dataframe

.by

optional grouping columns

Examples

Run this code
db = edc_example()
db$ae %>% colnames()
#`crfname` has one level for the whole dataset
db$ae %>% select_distinct() %>% colnames()
#`n_ae` has one level per patient
db$ae %>% select_distinct(.by=subjid) %>% colnames()

Run the code above in your browser using DataLab