I have cross sectional data and longitudinal data in a cohort:
# create dummy cross sectional data
cross_sec_df <- data.frame(ID = letters[1:10], severity = sample(c("mild", "severe"), 10, replace = TRUE))
# create example longitudinal data
long_df <- data.frame(ID = sample(cross_sec_df$ID, 50, replace = TRUE), date = sample(seq(as.Date('2010/01/01'), as.Date('2011/01/01'), by="day"), 50, replace = TRUE), plt = sample(100:300, 50, replace = TRUE), SOB = sample(c("yes", "no"), 50, replace = TRUE))
Each individual is categorized as either mild or severe. I would like to map the value of "severity" from the cross sectional data onto the longitudinal dataset; so the longitudinal dataset would have a new column "severity" where the values match the value in the cross-sectional data for the corresponding ID.