Re: [R] sorting & subsetting a data.frame

2011-03-07 Thread Liviu Andronic
On Mon, Mar 7, 2011 at 1:38 AM, David Winsemius wrote: > subset(x[order(x$Species1), ],  Sepal.Length==6.7 ) > Thank you all for the suggestions. Now I can do exactly what I wanted. Regards Liviu __ R-help@r-project.org mailing list https://stat.ethz.ch

Re: [R] sorting & subsetting a data.frame

2011-03-07 Thread David Winsemius
On Mar 6, 2011, at 7:34 PM, David Winsemius wrote: On Mar 6, 2011, at 6:05 PM, Liviu Andronic wrote: On Sun, Mar 6, 2011 at 11:53 PM, Liviu Andronic > wrote: On Sun, Mar 6, 2011 at 11:49 PM, Liviu Andronic > wrote: Dear all This may be obvious, but I cannot get it working. I'm trying to su

Re: [R] sorting & subsetting a data.frame

2011-03-06 Thread David Winsemius
On Mar 6, 2011, at 6:05 PM, Liviu Andronic wrote: On Sun, Mar 6, 2011 at 11:53 PM, Liviu Andronic > wrote: On Sun, Mar 6, 2011 at 11:49 PM, Liviu Andronic > wrote: Dear all This may be obvious, but I cannot get it working. I'm trying to subset & sort a data frame in one go. x <- iris x$Speci

Re: [R] sorting & subsetting a data.frame

2011-03-06 Thread Dennis Murphy
Hi: One approach is through the data.table package: library(data.table) df <- as.data.frame(data.table(iris, key = 'Species')[Sepal.Length == 6.7]) str(df) Using Species as a key variable automatically sorts by Species; the bracketing allows you to subset on Sepal.Length == 6.7. ddply() in the

Re: [R] sorting & subsetting a data.frame

2011-03-06 Thread David Winsemius
On Mar 6, 2011, at 5:49 PM, Liviu Andronic wrote: Dear all This may be obvious, but I cannot get it working. I'm trying to subset & sort a data frame in one go. x <- iris x$Species1 <- as.character(x$Species) ##subsetting alone works fine with(x, x[Sepal.Length==6.7,]) ##sorting alone works fin

Re: [R] sorting & subsetting a data.frame

2011-03-06 Thread Liviu Andronic
On Sun, Mar 6, 2011 at 11:53 PM, Liviu Andronic wrote: > On Sun, Mar 6, 2011 at 11:49 PM, Liviu Andronic > wrote: >> Dear all >> This may be obvious, but I cannot get it working. I'm trying to subset >> & sort a data frame in one go. >> x <- iris >> x$Species1 <- as.character(x$Species) >> ##sub

Re: [R] sorting & subsetting a data.frame

2011-03-06 Thread Liviu Andronic
On Sun, Mar 6, 2011 at 11:49 PM, Liviu Andronic wrote: > Dear all > This may be obvious, but I cannot get it working. I'm trying to subset > & sort a data frame in one go. > x <- iris > x$Species1 <- as.character(x$Species) > ##subsetting alone works fine > with(x, x[Sepal.Length==6.7,]) > ##sorti

[R] sorting & subsetting a data.frame

2011-03-06 Thread Liviu Andronic
Dear all This may be obvious, but I cannot get it working. I'm trying to subset & sort a data frame in one go. x <- iris x$Species1 <- as.character(x$Species) ##subsetting alone works fine with(x, x[Sepal.Length==6.7,]) ##sorting alone works fine with(x, x[order(Sepal.Length, rev(sort(Species1))),]