?aggregate Something like this should do it.
aggregate(xx[,1], list(xx[,2], median) --- On Fri, 8/1/08, stephen sefick <[EMAIL PROTECTED]> wrote: > From: stephen sefick <[EMAIL PROTECTED]> > Subject: Re: [R] simple help request > To: "Lotta R" <[EMAIL PROTECTED]> > Cc: r-help@r-project.org > Received: Friday, August 1, 2008, 2:36 PM > # I am sure there is a better way than this > a <- c(1,6,10,11,3,5,10) > group <- c(5,5,5,5,9,9,9) > my.df <- cbind(a,group) > a.5 <- subset(my.df, group==5) > median(a.5[,1]) > a.9 <- subset(my.df, group==9) > median(a.9[,1]) > > # MASS 4 is a good book > > On Fri, Aug 1, 2008 at 1:30 PM, Lotta R > <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > I have data that looks like > > > > number|grouping > > > > > > I would like to preform stats for each grouping > > > > so > > > > 1|5 > > 6|5 > > 10|5 > > 11|5 > > 3|9 > > 5|9 > > 10|9 > > > > Say I would like to take the median for above, I > should be returned 2 lines, > > one for group #5 and one for group #9 > > > > Does this make sense? > > > > I am sorry for the basic question, can someone give me > the name of a good > > book as well? > > > > Thanks, > > Lotta > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, > reproducible code. > > > > > > -- > Let's not spend our time and resources thinking about > things that are > so little or so large that all they really do for us is > puff us up and > make us feel like gods. We are mammals, and have not > exhausted the > annoying little problems of being mammals. > > -K. Mullis > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. __________________________________________________________________ [[elided Yahoo spam]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.