R sorting column -
i have file several column loaded in r. want achieve order column of file respect minimal value in each of column. e.g.
input(mina=0,minb=3,minc=1)
b c
4 8 1
2 3 4
0 3 1
output
b c
4 1 8
2 4 3
0 1 3
you might try apply()
way:
mins <- apply(mydata, 2, min) o <- order(mins) mydata <- mydata[,o]
Comments
Post a Comment