Skip to contents

Functions to clean and transform a drug use dataset:

  • clean_drug_use_data(): Standardizes variable types and handles missing values

  • classify_age_group(): Adds 'youth'/'adult' classification

  • save_data(): Writes processed data to file Clean the drug use dataset

Usage

clean_drug_use_data(data)

Arguments

data

A data frame that includes an age column

Value

A data frame with age converted to a factor and other columns to numeric.

Examples

df <- data.frame(age = c("18", "25"), cocaine = c("0", "-"))
clean_drug_use_data(df)
#>   age cocaine
#> 1  18       0
#> 2  25      NA