the R function mclapply() in the parallel package doesn't seem to work when rendering a quarto document #8734
Replies: 3 comments 4 replies
-
Did you try within an Rmarkdown document? ---
output: html_document
---
```{r}
library(parallel)
work <- function(n) {
ng <- 3
df <- tibble(x=c(rnorm(ng,100,15), rnorm(ng,100,15), rnorm(ng,100,15)),
g=factor(c(rep("group1",ng), rep("group2",ng), rep("group3",ng))))
summary(aov(x~g, data=df))[[1]]$"F value"[1]
}
nsims = 10000
ng = 3
n = rep(10, nsims)
results <- mclapply(n, work, mc.cores=16)
fvals <- rep(0, nsims)
for (i in 1:nsims) {
fvals[i] <- results[[i]]
}
fvals <- tibble(fvals)
``` |
Beta Was this translation helpful? Give feedback.
-
How did you do this instruction? Quarto has no special parallel handling; I think what's happening is that your configuration is not getting communicated to the library. |
Beta Was this translation helpful? Give feedback.
-
I thanks for the help I think I know what to do ![]() |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
The following R code when placed within a quarto document and rendered with
quarto preview
only uses 1 core even when instructed to use 16 cores (my machine has 16 cores).The identical code in an RStudio or R session does use all 16 cores.
Is this a limitation somehow of quarto?
Beta Was this translation helpful? Give feedback.
All reactions