Hello,
I have a data frame where I would like to "uncount", or expand, the rows of my data set based on two columns: column 1 is the persons id number and column 2 is the length of time that they've received treatment. When I use:
df<-df%>%dplyr::group_by(id)%>%uncount(MD)%>%dplyr::mutate(Expnd=row_number())
Where id = persons id and MD= month difference, which is a numerical value like 10, 25, etc.
When I run the code I get this error: Error in rep(seq_nrow(data), w) : invalid 'times' argument
My first guess was that there were rows where MD is NA, which isn't the case. Any thoughts on how to remedy this?