mardi 28 avril 2015

Make two random teams form dataset and get overall team score in R

Lets say I have a soccer team of 10 players (players) from which I should make two subteams of 5 players each and then compute the overall score for each team.

players <- read.table(text=
"paul    3
ringo   3
george  5
john    5
mick    1
ron     2
charlie 3
ozzy    5
keith   3
brian   3", as.is=TRUE)

I've already extracted a random set of 5 players:

t1 <- sample(players$V1, size = 5)

But one it comes to create the second team (excluding the players in the first one) and calculating the overall score for both teams I'm completed blocked.




Aucun commentaire:

Enregistrer un commentaire