Re: [R] using tapply with multiple variables

2011-05-01 Thread Andrew Robinson
This is a nice demonstration of the formula interface to aggregate. A less elegant alternative is to pass lists as arguments. with(dd, aggregate(Correct, by = list(Subject = Subject, Group = Group), FUN = function(x) sum(x == 'C')))

Re: [R] using tapply with multiple variables

2011-04-30 Thread Dennis Murphy
Hi: If you have R 2.11.x or later, one can use the formula version of aggregate(): aggregate(Correct ~ Subject + Group, data = ALLDATA, FUN = function(x) sum(x == 'C')) A variety of contributed packages (plyr, data.table, doBy, sqldf and remix, among others) have similar capabilities. If you wa

Re: [R] using tapply with multiple variables

2011-04-30 Thread Jim Lemon
On 05/01/2011 05:28 AM, Kevin Burnham wrote: HI All, I have a long data file generated from a minimal pair test that I gave to learners of Arabic before and after a phonetic training regime. For each of thirty some subjects there are 800 rows of data, from each of 400 items at pre and posttest.

Re: [R] using tapply with multiple variables

2011-04-30 Thread jim holtman
Since you did provide a description of your data (e.g., at least 'str(ALLDATA)') so that we know its structure, I will take a guess: tapply(ALLDATA$Correct, list(ALLDATA$Subject, ALLDATA$Time), function(x)sum(x=="C")) On Sat, Apr 30, 2011 at 3:28 PM, Kevin Burnham wrote: > HI All, > > I have a l