Re: [R] Reshape dataframe according to ordered variables

2010-03-18 Thread MORNEAU François
7 À : r-help Objet : [R] Reshape dataframe according to ordered variables Dear all, I am still a R apprentice... Apologies for the basic question. I am trying to reshape a dataframe based on the order of two variables (a character variable and a numerical variable). To simplify it, consider the f

Re: [R] Reshape dataframe according to ordered variables

2010-03-18 Thread jim holtman
try this: > df id ord 1 b 2 2 b 1 3 a 1 4 a 3 5 a 2 > df[order(df$id, df$ord),] id ord 3 a 1 5 a 2 4 a 3 2 b 1 1 b 2 > On Thu, Mar 18, 2010 at 11:27 AM, Duarte Viana wrote: > Dear all, > > I am still a R apprentice... Apologies for the basic question. > I am t

[R] Reshape dataframe according to ordered variables

2010-03-18 Thread Duarte Viana
Dear all, I am still a R apprentice... Apologies for the basic question. I am trying to reshape a dataframe based on the order of two variables (a character variable and a numerical variable). To simplify it, consider the following dataframe > df<-data.frame(id=c("b","b","a","a","a"),ord=c(2,1,1,