Skip to contents

Searches column names of given data.frame to identify which start with the given pattern. If the pattern given ends with 'N', it looks for variables that also end with N. If the pattern does not end with 'N', it excludes variables that end with 'N' while returning those that start with the pattern. eg. pattern = "BYVAR" may return c("BYVAR1","BYVAR2") Whereas "BYVARN" may return c("BYVAR1N","BYVAR2N"), if they exist.

Usage

var_start(df, pattern)

Arguments

df

data.frame input from which to get names

pattern

String. If not ends with N, only matches start. If ends with N, matches start and checks if column name ends in "N"

Value

Vector of column names starting with given pattern

Examples

data("ae_pre_process")

ae_pre <- mentry(
  datain = ae_pre_process$data,
  subset = NA,
  byvar = "AEBODSYS~SEX",
  trtvar = "TRTA",
  trtsort = "TRTAN",
  subgrpvar = NA,
  trttotalyn = "N",
  add_grpmiss = "N",
  sgtotalyn = "N",
  pop_fil = "SAFFL"
)

var_start(ae_pre, "BYVARN")
#> [1] "BYVAR1N" "BYVAR2N"
var_start(ae_pre, "BYVAR")
#> [1] "BYVAR1" "BYVAR2"