“在RMarkdown文件中使用job::job()时出现问题”

huangapple go评论73阅读模式
英文:

Issue using job::job() within RMarkdown file

问题

我正在编译一个大的RMarkdown文件,用于重现科学手稿的所有分析。其中一些分析需要很长时间,因此我使用了job::job()来将它们作为作业运行,当我在RStudio中逐步处理RMarkdown文件时,这个方法效果非常好。

但是,我想能够将RMarkdown文件编织成html/pdf以与手稿分享。但是,当我尝试渲染包含job::job()调用的第一个代码块时,出现错误:

错误 in check_available():!您必须从RStudio主会话中运行此操作。回溯:

job::job(...) job:::check_available() 执行中断

是否有什么我遗漏的内容,可以使渲染RMarkdown与包含作业部分成为可能?或者这只是基本上不兼容的(如果是这样,是否有关于如何在RMarkdown中实现类似作业运行情况的建议)?

英文:

I am working on compiling one large RMarkdown file that reproduces all of the analyses for a scientific manuscript. A few of the analyses take a long time, so I've used job::job() to run them as jobs, which has worked great when I'm working through the RMarkdown file in RStudio.

But, I'd like to be able to knit the RMarkdown file to html/pdf to share with the manuscript too. But I get an error in the first chunk that includes a job::job() call when trying to render:

> Error in check_available(): ! You must run this from the RStudio main
> session. Backtrace:
>
> job::job(...) job:::check_available() Execution halted

Is there something I'm missing that would make it possible to render the RMarkdown even with the job sections? Or is this just fundamentally incompatible (and if so, any suggestions for how to achieve a similar job-running situation within RMarkdown)?

答案1

得分: 0

I think this won't work. Jobs can only be used in an RStudio main session, and you could try using {future} and {callr} instead. See the following quotes:

job::job() is aimed at easing interactive development within RStudio. For tasks that don't benefit from running in the Jobs pane of RStudio, check out:

  • The future package's %<-% operator combined with plan(multisession).

  • The callr package is a general tool to run code in new R sessions.

英文:

I think this won't work. Jobs can only be used in an RStudio main session, and you could try using {future} and {callr} instead. See the following quotes:
>
>job::job() is aimed at easing interactive development within RStudio. For tasks that don't benefit from running in the Jobs pane of RStudio, check out:
>
> * The future package's %&lt;-% operator combined with plan(multisession).
>
> * The callr package is a general tool to run code in new R sessions.

huangapple
  • 本文由 发表于 2023年7月18日 07:24:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76708666.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定