Hi All, I have a data frame dat1: dat1 <-data.frame(N=seq(1, 12,1), B=c("29_log","29_log", "29_log", "27_cat", "27_cat", "1_log", "1_log", "1_log", "1_log", "1_log", "3_cat", "3_cat"))
Then I need to add one column or variable to reflect uniqueness of B variable in sequential order as below. dat1$C <-c(1,1,1,2,2,3,3,3,3,3,4,4) I only show 12 rows, my real data frame has over 1000 rows, I can not manually to add column C. It should be easy, but I can not figure out. Can you help me? Thanks, Ding --------------------------------------------------------------------- -SECURITY/CONFIDENTIALITY WARNING- This message (and any attachments) are intended solely f...{{dropped:22}} ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.