Hi:
Here's one approach. Let x be your matrix; then
table(apply(x, 1, which.max))
2 3
3 3
If you prefer the result in data frame form, then> as.data.frame(table(apply(x, 1, which.max)))
Var1 Freq
1 2 3
2 3 3
HTH,
Dennis
On Mon, May 31, 2010 at 2:39 AM, Noah Silverman
<noah@smartmediacorp.com>wrote:
> We're running Monte Carlo repeated measures for several groups.
>
> The goal is to determine the number of time each group has the highest
> score.
>
> A toy example:
>
> [,1] [,2] [,3]
> 0.1 0.2 0.3
> 0.1 0.2 0.3
> 0.1 0.2 0.3
> 0.1 0.3 0.2
> 0.1 0.3 0.2
> 0.2 0.3 0.1
>
> For this example: group 1 was the top 0 times, group 2 was the top 3
> times., group 3 was the top 3 times
>
> I can do this with some messy & statements or loops, but am looking for
> an easier way.
>
> Any suggestion?
>
> -N
>
> ______________________________________________
> R-help@r-project.org mailing list
> 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.
>
[[alternative HTML version deleted]]