Skip to content

Instantly share code, notes, and snippets.

@bussiere
Created November 30, 2017 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bussiere/042b40b875d46a80c81c460eae9bb96c to your computer and use it in GitHub Desktop.
Save bussiere/042b40b875d46a80c81c460eae9bb96c to your computer and use it in GitHub Desktop.
#Prediction Gaucher contre Droitier
datBeatRLU <- data.frame(character(9), numeric(9),numeric(9),stringsAsFactors = FALSE)
names(datBeatRLU)[names(datBeatRLU)=="character.9."] <- "HH"
names(datBeatRLU)[names(datBeatRLU)=="numeric.9."] <- "Value"
names(datBeatRLU)[names(datBeatRLU)=="numeric.9..1"] <- "HValue"
write.csv(datBeatRLU, file = "datBeatRLU.csv")
HandSwitch <- function(datBeatRLU,hand){
switch(hand,
RR={
datBeatRLU$Value[1] = datBeatRLU$Value[1] +1
datBeatRLU$HH[1] = hand
datBeatRLU$HValue[1] = 1
},
RL={
datBeatRLU$Value[2] = datBeatRLU$Value[2] +1
datBeatRLU$HH[2] = hand
datBeatRLU$HValue[2] = 2
},
RU={
datBeatRLU$Value[3] = datBeatRLU$Value[3] +1
datBeatRLU$HH[3] = hand
datBeatRLU$HValue[3] = 3
},
LL={
datBeatRLU$Value[4] = datBeatRLU$Value[4] +1
datBeatRLU$HH[4] = hand
datBeatRLU$HValue[4] = 4
},
LR={
datBeatRLU$Value[5] = datBeatRLU$Value[5] +1
datBeatRLU$HH[5] = hand
datBeatRLU$HValue[5] = 5
},
LU={
datBeatRLU$Value[6] = datBeatRLU$Value[6] +1
datBeatRLU$HH[6] = hand
datBeatRLU$HValue[6] = 6
},
UL={
datBeatRLU$Value[7] = datBeatRLU$Value[7] +1
datBeatRLU$HH[7] = hand
datBeatRLU$HValue[7] = 7
},
UR={
datBeatRLU$Value[8] = datBeatRLU$Value[8] +1
datBeatRLU$HH[8] = hand
datBeatRLU$HValue[8] = 8
},
UU={
datBeatRLU$Value[9] = datBeatRLU$Value[9] +1
datBeatRLU$HH[9] = hand
datBeatRLU$HValue[9] = 9
}
)
return(datBeatRLU)
}
for (i in 1:Size) {
lh <- smp[[i, "loser_hand"]]
wh <- smp[[i, "winner_hand"]]
if (!is.na(lh)&&!is.na(wh)){
datBeatRLU = HandSwitch(datBeatRLU, paste(wh, lh, sep=""))
}
}
write.csv(datBeatRLU, file = "datBeatRLU.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment