I'm having some issues adding months to a date in R, specifically I have a column "Date" that may or may not have a date and another column "Months" that may or may not have a positive integer. If there is both a date and integer I want to add them, something like this:
library(lubridate)
df$End <- ifelse(is.na(df$Start) | is.na(df$Months),"",df$Start %m+% months(ol$Months))
The error I keep getting is as follows:
Error in NextMethod(.Generic) :
NAs are not allowed in subscripted assignments
Any ideas? Thanks for your help.