Begin with R Begin with R - 2 months ago 6
R Question

cleaning the data R

I've got the final data

DS
such as :

|user_id
40 33
70 50
93 67
106 77
136 91
144 97
160 105
176 113
195 128
207 132
211 134
229 142
280 159
338 187
407 232
425 248
442 259
446 261
469 277
470 278
588 353
590 355
594 358
598 362
609 369
615 375
626 381
633 386
652 399
657 402
735 452
751 464
758 470
760 471
769 478
774 480
806 493
821 501
825 505
856 526
876 536
886 540
890 542
894 543
903 549
919 556
921 558
932 562


The fist column is a what left of line numbers I suppose, after many data manipulations,
and I'd like to drop them, nice, efficient way, and replace it with normal order numbers , 1,2,3,4,5 etc.

I did try to use :

aggr.cid <-aggregate(cbind(DS$user_id), by=list(CustID = DS$user_id),
function(x) x[1])


But instead of getting 1 line I'm getting two, with content of "user_id"
I can remove the second one and all will looks as I need but it is a doggy way....

Answer

Those are the row names. You can reset them with

rownames(DS) <- NULL
Comments