Hi All,
I am new to r studio and mostly using it to harmonized data using data frames or data tables.
I am in trouble handling duplicates in data frame.
Here is what inside data frame.
ID Value
1 109392p
2 208765ap
2 1208828z
1 zya10975p
1 2010789t
What I need is below
ID Value ID_new
1 109392p 1_1
2 208765ap 2_1
2 1208828z 2_2
1 zya10975p 1_2
1 2010789t 1_3
To simplify, I just need a unique key based on number of time my unique I'd occurs.
So in this example 1 is coming 3 times so new id will be 1_1,1_2,1_3 and same for second I'd
I tried logic using for loop it worked well but when I ran it for 1 million records it took more than hour and loop still running.
If anyone come up with a solution without loop that will help me to handle my problem is much appreciated.
Thanks
Anshu