I suspect the error is related to my lack of understanding of how to run this function multiple times using future_pmap; as you can see below I designate Ntrials to demonstrate that I desire the function to run 20 times in this particular scenario. Be mindful of the cores you are using if you wish to assist through replication of the code.
library("furrr")
library("parallel")
testmatrix<-matrix(runif((20000*11),-1,21),nrow = 20000, ncol = 11)
Testfunction<-function(ParVp,Ntrials){
for(simnum in 1:Ntrials){
#locate parameters for in-host dynamics
Vp=ParVp[, 1:2]
tp=ParVp[, 3:4]
lg=ParVp[, 5:6]
ld=ParVp[, 7:8]
Tc=ParVp[, 9:10]
rho=ParVp[, 11]
print(head(Vp))
}
}
ncores<-detectCores()-2
plan(multisession, workers = ncores)
Testoutput<- future_pmap(list(testmatrix,20),Testfunction)
plan(sequential)
Error in (function (.l, .f, …, .progress = FALSE) :
ℹ In index: 1.
Caused by error in ParVp[, 1:2]
:
! incorrect number of dimensions