This is similar to this question.
For every row, I have an ID and a Date. I wish to create a new column where the first Date of each ID is 1, the second Date of each ID is 2, etc...
Example:
library(data.table)
data = data.table(
id = c(1,1,1,2,2,3),
Row = c(1,2,3,4,5,6),
Date1 = c("2018-01-01",
"2018-01-05",
"2018-01-21",
"2018-02-01",
"2018-03-15",
"2018-04-01"))
The desired output would be a columns with
1,2,3,1,2,1