[R] Averaging column scores when participants vary in number of observations
John Kane
jrkrideau at inbox.com
Fri Feb 20 16:47:54 CET 2015
And just to muddy the waters more here's another way to do it using the handy plyr package where the data.frame is "dat1"
library(plyr)
ddply(dat1, .(Participant.ID), summarize, mean = mean(Score))
John Kane
Kingston ON Canada
> -----Original Message-----
> From: js.huang at protective.com
> Sent: Thu, 19 Feb 2015 17:36:19 -0800 (PST)
> To: r-help at r-project.org
> Subject: Re: [R] Averaging column scores when participants vary in number
> of observations
>
> Hi,
>
> Another implication:
>
>> data1
> Observation Participant.ID Video.Coder Score
> 1 A 1 Donald 4
> 2 B 1 Tracy 5
> 3 C 2 Donald 6
> 4 D 3 Sam 2
> 5 E 3 Tracy 3
> 6 F 4 Donald 2
> 7 G 4 Tracy 1
> 8 H 5 Sam 8
>> tapply(data1$Score,data1$Participant.ID,mean)
> 1 2 3 4 5
> 4.5 6.0 2.5 1.5 8.0
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Re-Averaging-column-scores-when-participants-vary-in-number-of-observations-tp4703549p4703561.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
____________________________________________________________
Can't remember your password? Do you need a strong and secure password?
Use Password manager! It stores your passwords & protects your account.
More information about the R-help
mailing list