I am trying to bootstrap in R but I can not figure out the right code. I have a set of 30 data points, either "yes" or "no". I was able to create 1000 bootstrap samples and retrieve the proportion of "yes" in each sample. Basically, if you convert the data to binary ("yes" = 1 and "no" = 0), then I was the mean of each bootstrap sample. I have tried both character and numeric data. Each time, the bootstrap returns 1000 values that are either 0 or 1/30. Clearly, there's no way that each bootstrapped sample only contains 1 or 0 "yes". I also can't figure out how to change the seed, so I keep getting the same numbers each time.
[count_yes <- function(d, i) {
d2 <- d[i,]
return(sum(d2$Empathy == "yes") / 30)
}
#create bootstrap
bootobject <- boot(CompassionateRatsFull, count_yes, R=1000)
fc <- function (data, indices) {
return(mean(data[indices]) / 30)
}
bootobject <- boot(ComRatsNum, fc, R=1000)][1]