tracks/r/exercises/tournament/example.R in trackler-2.1.0.21 vs tracks/r/exercises/tournament/example.R in trackler-2.1.0.22

- old
+ new

@@ -9,24 +9,30 @@ if (length(match) != 3 || !(match[3] %in% c("draw", "win", "loss"))) { next } else { # Process result - if (match[3]=="draw") { - results <- rbind(results, c(match[1], 1, 0, 1, 0, 1), c(match[2], 1, 0, 1, 0, 1)) - } else if (match[3]=="win") { - results <- rbind(results, c(match[1], 1, 1, 0, 0, 3), c(match[2], 1, 0, 0, 1, 0)) + if (match[3] == "draw") { + results <- rbind(results, + c(match[1], 1, 0, 1, 0, 1), + c(match[2], 1, 0, 1, 0, 1)) + } else if (match[3] == "win") { + results <- rbind(results, + c(match[1], 1, 1, 0, 0, 3), + c(match[2], 1, 0, 0, 1, 0)) } else { - results <- rbind(results, c(match[2], 1, 1, 0, 0, 3), c(match[1], 1, 0, 0, 1, 0)) + results <- rbind(results, + c(match[2], 1, 1, 0, 0, 3), + c(match[1], 1, 0, 0, 1, 0)) } } } - results[,2:6] <- sapply(results[,2:6], as.numeric) + results[, 2:6] <- sapply(results[, 2:6], as.numeric) - output <- aggregate(.~Team, results[-1,], sum) - output <- output[order(-output$P,output$Team), ] + output <- aggregate(.~Team, results[-1, ], sum) + output <- output[order(-output$P, output$Team), ] row.names(output) <- 1:nrow(output) output }