0

I have simple dataset, one row with factors - I'd like to create a second column (SEQ) and count/sequence the factor LO column

LO  SEQ
a   1
a   2
a   3
b   1
b   2

I want to count the LO factors like so...i.e. I want to create the SEQ column. Looks so easy - but I'm stuck.

PaulBeales
  • 475
  • 1
  • 8
  • 21

1 Answers1

0

We can use getanID

library(splitstackshape)
getanID(df1, 'LO')[]
#    LO .id
#1:  a   1
#2:  a   2
#3:  a   3
#4:  b   1
#5:  b   2
akrun
  • 874,273
  • 37
  • 540
  • 662