foreach partialPlot randomForest
<p>Trying to use <code>foreach</code> to plot the partial dependence plot from the <code>randomForest</code> package. Getting error:</p>

<p><code>Error in { : task 1 failed - undefined columns selected</code></p>

<pre><code> library(randomForest)
 library(DoParallel)
 library(mlbench)
 data(Sonar)
 registerDoParallel(8,cores=8)

Sonar.rrf &lt;- randomForest(
Sonar[-61],
Sonar[[61]],
ntree = 101,
oob.prox = FALSE,
importance = TRUE
)

Sonarimp &lt;- importance(Sonar.rrf)

m.list &lt;- foreach(
i = 1:10,
.combine = 'partialPlot',
.init = NULL,
.multicombine = TRUE,
.inorder = FALSE,
.packages = 'randomForest'
) %dopar%
{
impvar &lt;- rownames(Sonarimp)[order(Sonarimp[, 1], decreasing = TRUE)]
imptvar &lt;- impvar[i]
partialPlot(
  x = Sonar.rrf,
  pred.data = Sonar,
  x.var = imptvar,
  which.class = "R",
  xlab = imptvar,
  main = paste("Partial Dependence on", imptvar),
  ylim = c(30, 70)
)
}
</code></pre>