re<-read.delim(file="re.txt") meanbootsamp<-rep(NA,nrow(re)) for ( i in 1:nrow(re)){ x<-as.numeric(re[i,]) for(j in 1:10000){ data=sample(x,6,replace=TRUE,prob=NULL) meansamp=mean(data) meanbootsamp[j]=meansamp } pboot <- length(which(meanbootsamp[j]>=mean(x)))/10000 } 对循环还是有点晕,麻烦帮看一下,对meanbootsamp和pboot下标的定义好像有点问题。