Is there any easy code I can do the following task. Thanks.
From the file 1, collect 3 highest score of each id then output to the file 2.
File 1:
id score
hs_ref_chr1 1199
hs_ref_chr1 910
hs_ref_chr1 781
hs_ref_chr1 434
hs_ref_chr1 511
hs_ref_chr1 638
hs_ref_chr1 458
hs_ref_chr1 335
hs_ref_chr10 398
hs_ref_chr10 1106
hs_ref_chr16 272
hs_ref_chr16 1084
hs_ref_chr4 1162
hs_ref_chr4 1096
hs_ref_chr4 1090
hs_ref_chr4 1120
hs_ref_chr4 1701
hs_ref_chr4 1120
hs_ref_chr4 1152
File 2:
hs_ref_chr1 1199
hs_ref_chr1 910
hs_ref_chr1 781
hs_ref_chr10 1106
hs_ref_chr10 398
hs_ref_chr16 1084
hs_ref_chr16 272
hs_ref_chr4 1701
hs_ref_chr4 1162
hs_ref_chr4 1152
Thanks a lot.
From the file 1, collect 3 highest score of each id then output to the file 2.
File 1:
id score
hs_ref_chr1 1199
hs_ref_chr1 910
hs_ref_chr1 781
hs_ref_chr1 434
hs_ref_chr1 511
hs_ref_chr1 638
hs_ref_chr1 458
hs_ref_chr1 335
hs_ref_chr10 398
hs_ref_chr10 1106
hs_ref_chr16 272
hs_ref_chr16 1084
hs_ref_chr4 1162
hs_ref_chr4 1096
hs_ref_chr4 1090
hs_ref_chr4 1120
hs_ref_chr4 1701
hs_ref_chr4 1120
hs_ref_chr4 1152
File 2:
hs_ref_chr1 1199
hs_ref_chr1 910
hs_ref_chr1 781
hs_ref_chr10 1106
hs_ref_chr10 398
hs_ref_chr16 1084
hs_ref_chr16 272
hs_ref_chr4 1701
hs_ref_chr4 1162
hs_ref_chr4 1152
Thanks a lot.