I defined a function creates 3 random numbers from 1 to 36, and I allowed repetition. I want to test how many times I can get three same numbers in one hand in 1000 iterations using if statement inside the loop. I don't know what's happening there:
f <- function(all){
all <- seq(1:36)
hand <- sample(all, 3, replace=T)
return(c((hand),(sum(hand))))
}
f()
hand <- f()
hand
a=NaN
for (i in 1:1000){
hand[i] <- f()
if (hand[1]=hand[2]=hand[3]){
a[i]=TRUE
}else{
a[i]=FALSE
table(a)["TRUE"]
}
}