I have the following data.frame
ID<-c("ID_1","ID_2","ID_3","ID_5","ID_1008","ID_6","ID_10")
SomethingElse<-c(5,6,7,1,2,3,1)
SomeText<-c("Thank","you","for","the","!","help","!")
df<-data.frame(ID,SomethingElse,SomeText)
what i need is to order the data.frame according to the ID column but in regard to the Numbers within it (1,2,3,5,1008,6,10), so that the result looks like:
ID SomethingElse SomeText
ID_1 5 Thank
ID_2 6 you
ID_3 7 for
ID_5 1 the
ID_6 3 help
ID_10 1 !
ID_1008 2 !
My problem is when using the command df[order(df$ID),]
it orders the result in lexicographical order
which is "wrong" and looks like the following:
ID SomethingElse SomeText
ID_1 5 Thank
ID_10 1 !
ID_1008 2 !
ID_2 6 you
ID_3 7 for
ID_5 1 the
ID_6 3 help
Is there any smooth and fast one-liner to solve this issue?