[R] Sort 1-column dataframe with rownames
Johannes Radinger
JRadinger at gmx.at
Fri Jun 8 09:22:45 CEST 2012
Hi,
I have a 1-column dataframe with rownames and I want to sort it
based on the single column. The typical procedure that is recommended
in diverse posts is to use order in the index. But that "destroys" my
dataframe structure. Probabaly it is a very simple solution. Here is a
short reproducable example:
x <- c(1,3,51,2,34,44,12,33,2,8)
df <- data.frame(x)
rownames(df) <- c("A","B","C","D","E","F","G","H","I","J")
df.sort <- df[order(df[,"x"]),]
/Johannes
--
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
More information about the R-help
mailing list