Thank you all for your help, This is what I was able to do aggregate(items,items[2],mean)
Where items has all my data, and items[2] has my group id number. Here are my 2 questions 1) items[1] has a unquie number in it, how do I tell mean to take the mean of items[3] not items[1] 2) Is there an easy way to add a count of items[1] for each items[2]. In other words, when it aggregates, I want to know how many items are in each group. Thanks, Lotta On Fri, Aug 1, 2008 at 2:47 PM, Jorge Ivan Velez <[EMAIL PROTECTED]>wrote: > > Dear Lotta, > > Try > > my.df <- data.frame(a <- c(1,6,10,11,3,5,10), group <- c(5,5,5,5,9,9,9)) > tapply(my.df$a,my.df$group,median) > 5 9 > 8 5 > > See ?tapply and/or ?aggregate for more information. > > HTH, > > Jorge > > > > > 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<http://www.r-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> > > [[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.