calculating timeframe accuracy in R [closed]

A possible solution would be to express your need in a case_when.

df %>%
  dplyr::mutate(DIF = case_when(discharge_calender_date < discharge_prediction_lower_bound ~ discharge_calender_date - discharge_prediction_lower_bound,
                                discharge_calender_date <= discharge_prediction_upper_bound ~ 0,
                                TRUE ~ discharge_calender_date - discharge_prediction_upper_bound))

This way you get a negative value if the patient left before the lower bound, zero if he left within the prediction and a positive result if he left after the prediction.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top