Entering edit mode
6.2 years ago
majeedaasim
▴
60
I have two files;
File one:
ID SCORE PVALUE
A 1 0.1
B 2 0.2
C 3 0.3
D 4 0.4
FIle 2:
ID
C
B
A
Now I want to reorder my file 1, in the sequence as present in file 2.
THanks
And what have you tried to solve this?
In R, just set the column as factor with your levels for the dataframe.
For others, storing the levels in a hashmap with incremental numbers as values, then you can sort the rows using corresponding hashmap value.
Want save time? csvtk sort supports sorting by user defined levels.
Do you want a solution in Perl, Python or R?
I want solution in R
why not trying googling using keywords "r dataframe reorder factor"?