This function extracts the cohort ID (e.g., SAB) from the subject ID (e.g., SubjectID). By default it takes the first three characters.

extract_cohort(dat, id_var, st, en)

Arguments

dat

A dataframe containing the variables of interest. A dataframe.

id_var

The variable name to be used to identify subjects. A string.

st

Integer indicating the first element to be extracted. An integer.

en

Integer indicating the last element to be extracted. An integer.

Value

A dataframe containing a new column named cohort. A dataframe.