This function accepts two data frames. One is a USRDS longitudinal cohort. The second is a data frame with dates representing covariates. The resulting output is a USRDS longitudinal cohort with the covariates added to the data frame as time-varying covariates.
Usage
add_cohort_covariate(
USRDS_cohort,
covariate_data_frame,
covariate_date,
covariate_value = NULL,
covariate_variable_name
)Arguments
- USRDS_cohort
is a USRDS cohort created using the
create_usrds_cohort()function- covariate_data_frame
is a data frame with a date variable (delineated via the
covariate_dateoption).- covariate_date
is a character string naming a date variable in
covariate_data_framethat specifies the date of onset of the covariate- covariate_value
is an optional variable which encodes the value taken by the time-dependent covariate on the date encoded in
covariate_date. Ifcovariate_valueis not specified,- covariate_variable_name
is a string with the variable name for the new covariate variable created
Value
A USRDS longitudinal cohort with additional rows created as needed
and a new time-varying covariate column named covariate_variable_name.
