Skip to content
Prev 164760 / 398506 Next

how to create duplicated ID in multi-records per subject dataset

if the records are in the file dupIDs.txt, then when you read them in,
the IDs become factors.  Coercing them to numeric gets them to assign
a unique number to each factor.

So, you could try the following:

dupIDs <- read.table("dupIDs.txt", header = T)
dupIDs$ID2 <- cummax(as.numeric(dupIDs$ID)-1)
ID record ID2
1  1     20   1
2  .     30   1
3  .     25   1
4  2     26   2
5  .     15   2
6  3     21   3

HTH,

Andrew.
On Dec 15, 12:56?pm, "Zhixin Liu" <z... at efs.mq.edu.au> wrote: