I think what you want to write is: by(your.df, quiz, function(.sub){ t.test(percent ~ group, data=.sub) }
On 10/22/07, Matthew Dubins <[EMAIL PROTECTED]> wrote: > I've tried to use by(), but the closest i got to it doing what I wanted > was using the following: > > by(percent, quiz, function(percent) {t.test(percent~group, > data=marks.long)}) > > But the results it gave me weren't t.tests of percent by group according > to quiz number. > > > Julian Burgos wrote: > > See by() > > > > Matthew Dubins wrote: > >> Hi all, > >> > >> I wrote a simple function that gives me multiple t.test results > >> according to a subset variable and am wondering whether or not I > >> reinvented the wheel. Observe: > >> > >> t.test.sub <- function (formula, data, sub, ...) > >> { > >> for(i in 1:max(sub)) > >> { > >> print(t.test(formula, data = subset(data, sub == i), > >> ...)) > >> } > >> } > >> > >> Is there already a similar function in some package? > >> > >> Thanks, > >> Matthew Dubins > >> > >> ______________________________________________ > >> 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. > > > > ______________________________________________ > 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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? ______________________________________________ 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.