I have the following sample data frame in R.
item index ptr
A 1 0.40
B 2 NA
C 3 0.30
D 4 0.35
E 5 0.44
F 6 NA
It is already sorted by = column index. Now I would like to sort it by column ptr, but leaving the position of the rows, where ptr= NAuntouched. Therefore, I expect:
item index ptr
C 3 0.30
B 2 NA
D 4 0.35
A 1 0.40
E 5 0.44
F 6 NA
Normal df = df[order(ptr),]does not work. Any ideas? Thank you very much in advance.
source
share