Learn R Programming

staggR (version 0.1.1)

prep_data: Prepare a data frame to work with sdid() function

Description

Prepare a data frame to work with sdid() function

Usage

prep_data(df, cohort_var, cohort_ref = NULL, time_var, time_ref = NULL)

Value

data.frame

Arguments

df

A data frame containing the variables in the model.

cohort_var

String specifying the name of the column in df that defines the intervention cohorts.

cohort_ref

An optional string specifying the value of cohort_var to be used as the referent in the model. If not specified, the value is taken from the first observed value in cohort_var.

time_var

String specifying the name of the column in df that defines time periods over the study.

time_ref

An optional string specifying the value of time_var to be used as the referent in the model.

Examples

Run this code
dta_prepped <- prep_data(hosp,
                         cohort_var = "cohort",
                         cohort_ref = "0",
                         time_var = "yr",
                         time_ref = "2010")
head(dta_prepped)

Run the code above in your browser using DataLab