Hello,
I have a data frame with multiple IDs, I'm trying to write a code which will sequence out by column BDate and grouped by ID. For Example, ID A's BDate is equal to 2014-01-27 so the next row will be 2014-02-27 followed by 2014-03-27...etc.
I tried using the sequence function seq but I get this error Error in seq.Date(as.Date(BDate), by = "month", length.out = Span) : 'from' must be of length 1
Any ideas on how I can properly get this sequence to execute?
df<-data.frame(ID=c("A","B"),BDate=c("2014-01-27","2014-03-31"),Span=c(10,10))
df <- df[rep(row.names(df), df$Span),]
df2<-df%>%group_by(ID)%>%mutate(PDate=seq(as.Date(BDate), by = "month", length.out =Span ))