I want to sort R
data.frame
when it has only one column. How can I get the output as data.frame
(Output should be a data.frame with rownmaes)? Thanks in advance for your help.
set.seed(12345)
df <- data.frame(X=rnorm(n=10, mean=0, sd=1))
rownames(df) <- LETTERS[1:10]
df
X
A 0.5855288
B 0.7094660
C -0.1093033
D -0.4534972
E 0.6058875
F -1.8179560
G 0.6300986
H -0.2761841
I -0.2841597
J -0.9193220
df[order(df$X), ]
[1] -1.8179560 -0.9193220 -0.4534972 -0.2841597 -0.2761841 -0.1093033
[7] 0.5855288 0.6058875 0.6300986 0.7094660