So I would like to remove from my data the rows which has the same "id" (in this case it's 221 and 341) As you see the values in other columns are different so I would like to delete duplicated rows (same id) but I still would like to keep the one of the rows.
>head(data)
id Sequence Score variable value
221 AAIYKLLKSHF 30.87 BiotinControl1_2 221498.368
341 EKPLFLVFHGT 42.04 BiotinControl1_2 255198.8712
330 FMIAPTGAKTF 49.67 BiotinControl1_2 1526577.651
221 FMIAPTGAKTF 40.69 BiotinControl2 429384.4861
341 GKLKGVLGYTE 39.34 BiotinTreatment1 597884.8329
196 IKKVVKAAAE 39.81 BiotinControl1_2 2277435.528
117 IKKVVKAAAE 44.86 BiotinControl1_2 1050394.325
so that's how should my data looks like:
id Sequence Score variable value
221 AAIYKLLKSHF 30.87 BiotinControl1_2 221498.368
341 EKPLFLVFHGT 42.04 BiotinControl1_2 255198.8712
330 FMIAPTGAKTF 49.67 BiotinControl1_2 1526577.651
196 IKKVVKAAAE 39.81 BiotinControl1_2 2277435.528
117 IKKVVKAAAE 44.86 BiotinControl1_2 1050394.325
Which function should I use to do something like that ?
Use duplicated
dat[!duplicated(dat$id),]
id Sequence Score variable value
1 221 AAIYKLLKSHF 30.87 BiotinControl1_2 221498.4
2 341 EKPLFLVFHGT 42.04 BiotinControl1_2 255198.9
3 330 FMIAPTGAKTF 49.67 BiotinControl1_2 1526577.7
6 196 IKKVVKAAAE 39.81 BiotinControl1_2 2277435.5
7 117 IKKVVKAAAE 44.86 BiotinControl1_2 1050394.3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.