2
我運行此代碼的foreach錯誤 「無法找到函數 」%做%「」
....
niters = 1000
mFR <- foreach(i=1:iters, .combine=rbind) %dopar% {
foreach(j=1:iters, .combine=c) %do% {
mp2 <- mp[sample(1:1e6, iters)]
fexist = 0
if (mp2[j]>mR12[i]) {
Frv = 1
fexist = 1
} else if (mp2[j]<=mRy2[i]) {
Frv = 0
fexist = 1
} else {
if (mRy2[i]>mR12[i]) {
Frv = 1
} else {
fexist = 1
b = mDMDuc1[i]/(1-mR12[i]/mRy2[i])
m = -b/mRy2[i]
DMDp = m*mp2[j] + b
Frv = (DMDp - 0)/(mDMDc2[i] - 0)
}
}
if (fexist==1) {
mFR <- matrix(Frv, ncol=1, nrow = 1)
mFR
}
}
}
任何想法,爲什麼這個錯誤發生時,我得到
Error in { : task 1 failed - "could not find function "%do%""
?謝謝!
它的工作原理!完善。謝謝 – jpcgandre 2014-09-11 10:21:26