Re: [R] sorting a data.frame by mean values of grouped data

2008-03-12 Thread sjbarry
Thanks Mark, I see that I made an error in my original request for help. I got my labels and groups mixed up (see below). Nonetheless, your code has been a good pointer in the direction of a solution. I'll post it up when I have it working. Thanks again, Stephen Barry. I should have written i

Re: [R] sorting a data.frame by mean values of grouped data

2008-03-12 Thread Mark W Kimpel
Stephen, I am sure someone will have a more elegant solution, but the following works. Mark d.lst <- split(x = d, f = as.factor(d$Group), drop = FALSE) d.lst.mn <- sapply(d.lst, FUN = function(x){mean(as.numeric(as.character(x$Value)))}) o <- order(d.lst.mn, decreasing = TRUE) d.lst.mn <- d.lst

[R] sorting a data.frame by mean values of grouped data

2008-03-12 Thread sjbarry
Hi, I have what I think is a fairly straightforward problem. I've looked through the FAQ's and mailing lists but have been unable to identify a solution, probably because I don't understand the language well enough. I have a set of data d, with 3 columns as shown, I want to sort the data Group,