Hi,
I've gone through documentation related to deduplication but I have slightly different challenge. I have this data frame:
data.frame(
VitalCode = c(223L, 221L, 221L, 221L, 2415L),
Accountnum = as.factor(c("A", "A", "A", "A", "B")),
RoDate = as.factor(c("17/12/2012 00:00", "05/03/2013 00:00",
"15/03/2013 00:00",
"10/06/2014 00:00",
"26/06/2019 00:00")),
MOTFlag = as.factor(c("NO", "NO", "NO", "YES", "NO"))
)
I don't really need to use unique records from " Accountnum". I would like to assign their order based on "RoDate" so New variable should have following values:
Sequence <- c(1, 2, 3, 4, 1)
Can we also have it based only on year rather than a full date? In this case the result I need should be:
SequenceYear <- (1, 2, 2, 3, 1)
Is it simple? Most of issues R users have are related to deduplications only...