[R] add one variable to a data frame
Ding, Yuan Chun
ycding @ending from coh@org
Fri May 11 19:52:13 CEST 2018
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}}
More information about the R-help
mailing list