[R] tapply problem
Robin Hankin
r.hankin at auckland.ac.nz
Thu Oct 18 05:21:58 CEST 2001
Hello everybody.
I have a question that has stumped me and the usual "apply" tricks
don't seem to work. I run a course where each student's performance
is marked by one or more assessors.
I have a data frame containing students' names, assessors' names and
their marks, arranged as follows:
ID student assessor Q1A Q1B Q1C Q2A Q2B Q3
1 2152833 Fred.Smith Robin 15.0 17.0 13.0 14.0 13.0 8.0
2 2152833 Fred.Smith Steph 14.0 13.0 11.0 16.0 13.0 8.0
3 2152833 Fred.Smith Julie 15.0 17.0 13.0 17.0 13.0 8.0
4 9821091 Joe.Bloggs John 13.0 12.0 12.0 15.0 12.0 8.0
5 9821091 Joe.Bloggs Julie NA NA NA 18.0 14.0 8.0
6 9821091 Joe.Bloggs Robin 12.0 12.5 NA 16.0 13.5 8.0
7 9821091 Joe.Bloggs Steph NA NA 12.0 17.0 12.5 NA
8 9791734 Bob.Jones Julie 13.0 12.0 8.0 16.0 13.0 8.0
9 9791734 Bob.Jones Robin 11.0 12.0 7.0 14.0 11.0 8.0
...
note that some students are marked by more assessors than others.
What I want is each student's mean mark for each question, averaged
over the appropriate assessors. Is there a neat vectorized method I
could use?
The best I can come up with is "tapply(x$Q1A,x$name,mean,na.rm=T)" but
this works question-by-question and I would like a reduced data frame
with the same column headings.
this is driving me crazy; thanks in advance!
--
Robin Hankin, Lecturer,
School of Environmental and Marine Science
Private Bag 92019 Auckland
New Zealand
r.hankin at auckland.ac.nz
tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042
--f9295XO03655.1002013533/r.hankin.sems.auckland.ac.nz--
--
Robin Hankin, Lecturer,
School of Environmental and Marine Science
Private Bag 92019 Auckland
New Zealand
r.hankin at auckland.ac.nz
tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list