Select or remove study variables
Arguments
- data
Base
data.frame, or asimulab_sim.- keep
Variables to retain, in the order given. A character vector of column names, or
NULL(the default).- drop
Variables to remove, the others keeping their order. A character vector of column names, or
NULL(the default). Only one ofkeepanddropmay be given.
Examples
data <- data.frame(id = 1:5, keep_me = 1:5, drop_me = 6:10)
select_variables(data, keep = c("id", "keep_me"))
#> <simulab_sim:selected_variables> 5 rows x 2 columns
#> id keep_me
#> 1 1 1
#> 2 2 2
#> 3 3 3
#> 4 4 4
#> 5 5 5
select_variables(data, drop = "drop_me")
#> <simulab_sim:selected_variables> 5 rows x 2 columns
#> id keep_me
#> 1 1 1
#> 2 2 2
#> 3 3 3
#> 4 4 4
#> 5 5 5