[R] Games
peter dalgaard
pdalgd at gmail.com
Fri Aug 13 17:22:39 CEST 2010
On Aug 13, 2010, at 5:15 PM, peter dalgaard wrote:
>
> On Aug 13, 2010, at 4:45 PM, Michael Bedward wrote:
>
>> teams <- LETTERS[1:11]
>> matches <- combn(teams, 2)
>> draw <- data.frame(team1=matches[1,], team2=matches[2,])
>>
>> # someone will know how to do this in one line...
>> time <- numeric(55)
>> k <- 0
>> for (i in 1:10) {
>> t0 <- 2*i - 1
>> n <- 10 - i + 1
>> for (j in t0:(t0+n-1)) {
>> k <- k+1
>> time[k] <- (j-1) %% 10 + 1
>> }
>> }
>
> Shouldn't there be 11 rounds? This way you have one team playing twice in every round.
Sorry, make that 2 teams playing twice in every other round. Every team playing twice in one round once. I was reading the table transposed:
> table(draw$team1,time) + table(draw$team2,time)
time
1 2 3 4 5 6 7 8 9 10
A 2 1 1 1 1 1 1 1 1 1
B 1 1 2 1 1 1 1 1 1 1
C 1 1 1 1 2 1 1 1 1 1
D 1 1 1 1 1 1 2 1 1 1
E 1 1 1 1 1 1 1 1 2 1
F 2 1 1 1 1 1 1 1 1 1
G 1 1 2 1 1 1 1 1 1 1
H 1 1 1 1 2 1 1 1 1 1
I 1 1 1 1 1 1 2 1 1 1
J 1 1 1 1 1 1 1 1 2 1
--
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-help
mailing list