I have this code for creating a matrix out of some calculations using a function "cop.theta" in a for loop environment
Mat.corr <- matrix(0,6,5,byrow=F)
for (i in 1:6){
Mat.corr[i,]=cop.theta(index,EXPR,SURV=survp[,i])
}
I wrote an R code using "foreach" in doParallel package to get results that is similar to what the code above generated. My code is as follows
library(doParallel)
cl <- makeCluster(3)
registerDoParallel(cl)
getDoParWorkers()
clusterExport(cl, list("QT","EXPR","cop.theta.i"))
clusterEvalQ(cl, library(copula))
foreach(i=1:6,.combine=matrix(0,6,5,byrow=F) %dopar%
Mat.corr[i,]=cop.theta(index,EXPR,QT=survp[,i])
But I'm getting this error
Error: unexpected '=' in "foreach(i=1:6,.combine=matrix(0,6,5,byrow=F)
%dopar% Mat.corr[i,]="
Where I'm I going wrong?