Skip to content
Prev 171405 / 398503 Next

"autonumber" for grouping variable

say 'dat' is your data frame, then one way is the following:

f <- factor(dat$Id, levels = unique(dat$Id))
dat$Number <- unclass(f)
dat


I hope it helps.

Best,
Dimitris
clion wrote: