[R] Repeating a R code and counting how many repetitions working

varin sacha v@r|n@@ch@ @end|ng |rom y@hoo@|r
Sat Dec 11 11:47:21 CET 2021


Dear R-experts,

Here below my R code. I am trying to do 2 things :

1) I would like to repeat this R code 10000 times

2) Out of the 10000 repetitions I would have liked R to tell me how many times the "true" mean value of the population called "s" in my R example here below is included in the 10000 BCa confidence intervals constructed.

Many thanks for your precious help.

########################################
library(boot)

s= sample(178:798, 10000, replace=TRUE)
mean(s)

a=sample(s,size=5)
mean(a)

dat<-data.frame(a)
med<-function(d,i) {
temp<-d[i,]
mean(temp)

}
boot.out<-boot(data=dat,statistic=med,R=10000)
boot.ci(boot.out,type="bca")
########################################



More information about the R-help mailing list