I have dataframe with two columns (target_id and fpkm). I want to keep only those in first column that are not duplicated. If they are duplicated then i would like to keep only one based on value in column 2. I have given an example for this kind below.
target_id fpkm
comp247393_c0_seq1 3.197885
comp257058_c0_seq4 1.624577
comp242590_c0_seq1 1.750319
comp77911_c0_seq1 1.293059
comp241426_c0_seq1 1.626589
comp288413_c0_seq1 14.828853
comp294436_c0_seq1 11.555596
comp63603_c0_seq1 1.982386
comp267138_c0_seq1 8.594494
comp267138_c0_seq2 11.134958
comp321623_c0_seq1 6.934149
In the above dataframe as you can see there are two rownames with the same name (almost) comp267138_c0_seq1 comp267138_c0_seq2 and i want to keep only comp267138_c0_seq2 because it has higher value in column 2. Please help me with this....
target_id fpkm
comp247393_c0_seq1 3.197885
comp257058_c0_seq4 1.624577
comp242590_c0_seq1 1.750319
comp77911_c0_seq1 1.293059
comp241426_c0_seq1 1.626589
comp288413_c0_seq1 14.828853
comp294436_c0_seq1 11.555596
comp63603_c0_seq1 1.982386
comp267138_c0_seq1 8.594494
comp267138_c0_seq2 11.134958
comp321623_c0_seq1 6.934149
In the above dataframe as you can see there are two rownames with the same name (almost) comp267138_c0_seq1 comp267138_c0_seq2 and i want to keep only comp267138_c0_seq2 because it has higher value in column 2. Please help me with this....
Comment