[R] How create vector that sums correct responses for multiple subjects?

2011-03-24 Thread Kevin Burnham
I have a data file with indicates pretest scores for a linguistics experiment. The data are in long form so for each of 33 subjects there are 400 rows, one for each item on the test, and there is a column called ‘Correct’ that shows ‘C’ for a correct response and ‘E’ for an incorrect response. I

Re: [R] How create vector that sums correct responses for multiple subjects?

2011-03-24 Thread Sarah Goslee
Try this: tapply(mydata$Correct, mydata$Subject, function(x)sum(x == C)) Sarah On Thu, Mar 24, 2011 at 3:24 PM, Kevin Burnham kburn...@gmail.com wrote: I have a data file with indicates pretest scores for a linguistics experiment.  The data are in long form so for each of 33 subjects there

Re: [R] How create vector that sums correct responses for multiple subjects?

2011-03-24 Thread Jorge Ivan Velez
Hi Kevin, Try this (untested): sapply(split(pretestdata, Subject), function(l) with(l$Correct == C)) HTH, Jorge On Thu, Mar 24, 2011 at 3:24 PM, Kevin Burnham wrote: I have a data file with indicates pretest scores for a linguistics experiment. The data are in long form so for each of 33

Re: [R] How create vector that sums correct responses for multiple subjects?

2011-03-24 Thread Hadley Wickham
On Thu, Mar 24, 2011 at 2:24 PM, Kevin Burnham kburn...@gmail.com wrote: I have a data file with indicates pretest scores for a linguistics experiment.  The data are in long form so for each of 33 subjects there are 400 rows, one for each item on the test, and there is a column called