Hi, Following please find *some* of my data.
percent quiz group 100 1 High 100 1 High 100 1 High 25 1 Low 50 1 Low 75 1 High 50 1 Low 75 1 High 100 1 High 100 1 High 50 1 Low 60 2 High 20 2 High 100 2 High 60 2 Low 40 2 Low 80 2 High 20 2 Low 60 2 High 40 2 High 100 2 High 90 3 High 100 3 High 0 3 High 90 3 Low 80 3 High 60 3 Low 100 3 High 60 3 High Here is the by command i used: by(percent, quiz, function(percent) {t.test(percent~group, data=marks.long)}) Basically it gave me three of the same t.tests based on the full data set, not the subsets (quiz 1, 2 and 3). So far it seems like my method is more straightforward! Julian Burgos wrote: > Could you post some of your data and your initial test, and explain > why it didn't worked? It is difficult to figure out what is the > problem with your call to by(). > > Julian > > Matthew Dubins 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. >>> >> > [[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.