How to add months to the follow-up missing dates


I have a longitudinal data set and I'm struggling to add the missing dates for the follow-up based on the baseline date of visit. Would be great to receive your help.

My code is:

test <- test %>%
group_by(study_id) %>%
filter(Visit == 1) %>% # 1st visit after baseline which is at 6 months
mutate(new_var = if_else(, dmy(dateofrandomisation) %m+% month(6),0))

I'm getting the following error: Error in as.POSIXlt.numeric(x) : 'origin' must be supplied

Hi, welcome!

We don't really have enough info to help you out. Could you ask this with a minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

If you've never heard of a reprex before, you might want to start by reading this FAQ:


I have attached an image to better understand the dataset.



An image is not very helpful, we can't copy from it, and is not a polite thing to do here, please read the guide I gave you and try to make a proper reproducible example.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.