[R] Games
Michael Bedward
michael.bedward at gmail.com
Fri Aug 13 16:45:58 CEST 2010
OK, second attempt. I think this one is a goer (hope)...
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
}
}
draw$time <- time
How's that ?
Michael
More information about the R-help
mailing list