Printing from mclapply in R Studio

后端 未结 3 2153
迷失自我
迷失自我 2021-02-19 06:54

I am using mclapply from within RStudio and would like to have an output to the console from each process but this seems to be suppressed somehow (as mentioned for example here:

3条回答
  •  悲&欢浪女
    2021-02-19 07:15

    Here's a workaround which uses shell echo to print to R console in Rstudio:

    #' Function which prints a message using shell echo; useful for printing messages from inside mclapply when running in Rstudio
    message_parallel <- function(...){
      system(sprintf('echo "\n%s\n"', paste0(..., collapse="")))
    }
    

提交回复
热议问题