Re: [R] Sort 1-column dataframe with rownames

2012-06-08 Thread arun
Hi, Try this, df.sort<-apply(df,2,sort) > df.sort    x A  1 D  2 I  2 B  3 J  8 G 12 H 33 E 34 F 44 C 51 df.sort<-as.data.frame(df.sort) A.K. - Original Message - From: Johannes Radinger To: R-help@r-project.org Cc: Sent: Friday, June 8, 2012 3:22 AM Subject: [R] Sort

Re: [R] Sort 1-column dataframe with rownames

2012-06-08 Thread Johannes Radinger
Hi Achim, thank you for your good explanation and the solution to my question... cheers, /j Original-Nachricht > Datum: Fri, 8 Jun 2012 09:30:42 +0200 (CEST) > Von: Achim Zeileis > An: Johannes Radinger > CC: R-help@r-project.org > Betreff: Re: [R] Sort 1-c

Re: [R] Sort 1-column dataframe with rownames

2012-06-08 Thread Ivan Calandra
Hi Johannes, You need to add the drop=FALSE argument in order to keep the structure: df.sort <- df[order(df[,"x"]), , drop=FALSE] ## don't forget the extra comma See ?"[" for details HTH, Ivan -- Ivan CALANDRA Université de Bourgogne UMR CNRS/uB 6282 Biogéosciences 6 Boulevard Gabriel 21000

Re: [R] Sort 1-column dataframe with rownames

2012-06-08 Thread Achim Zeileis
On Fri, 8 Jun 2012, Johannes Radinger wrote: 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 ver

[R] Sort 1-column dataframe with rownames

2012-06-08 Thread Johannes Radinger
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