我正在使用 tapply() 将函数应用于我的数据
Myrepfun <- function(x,n){
nstudents <- replicate(1000,sum(sample(x, size=n,replace=TRUE)))
quantile(nstudents,probs=0.95)
}
tapply(weight,schoolcode,Myrepfun,n=2)
我想在 for 循环中使用它并打印输出。我尝试了以下方法并收到错误消息:Error: unexpected symbol in "for(n in 12:13) (t=tapply(ow,sc,ndropfunction,n,p=0.95) output
for(n in 1:25) {t=tapply(weight,schoolcode,Myrepfun,n,p=0.95) print(c=(t,n))}