[R] looking for something like "ave" I can pass non numeric to
John Christie
jc at or.psychology.dal.ca
Mon Apr 19 14:41:07 CEST 2004
Hi,
I have been trying to calculate summary error and coding statistics on
a by subject basis and seem to be writing a lot of code to do a simple
thing. I won't go into my messy version. What I am asking is if
anyone knows of a single command that could take the following data and
get error rates over a given vector.
Given data from ss with,,,
subj a rt code
1 1 200 good
1 1 321 good
1 2 457 good
1 2 384 bad
2 1 228 good
2 1 343 bad
....
I would like to do a calculation something like ave returns. An
artificial example that does not work where I have passed the code
field to ave is below.
ss$FAcount<- ave(ss$code, ss$subj, function(x)
length(x[x=="good"])/length(x))
More information about the R-help
mailing list