我正在尝试使用Rstudio中的.R脚本连续渲染几个Radix .Rmd文件。
---
title: Title
description: |
Test
author:
- name: Matt
url:
date: "`r Sys.Date()`"
output: radix::radix_article
editor_options:
chunk_output_type: console
---
```{r debug}
sessionInfo()
```
当我使用callr
包来确保每个文件都是通过新的会话呈现时,出现此错误,这阻止了下一个调用的完成:
> library(rmarkdown)
> callr::r(render("test.Rmd"))
Error in eval(substitute(expr), data, enclos = parent.frame()) :
no("func") || is.function(func) is not TRUE
按照建议的here,我使用了一个函数将对render()
的调用包装到一个更大的函数中:
render_new_session <- function(...) {
callr::r(
function(...) { suppressMessages(rmarkdown::render(...)) },
args = list(...),
show = F,
spinner = T
)
}
使用此功能时,出现有关在Rstudio中进行预览的错误,这也阻止了下一个调用的完成:
> render_new_session("test.Rmd")
Error: Radix articles cannot be previewed in this version of RStudio.
Please update to version 1.2.718 or higher at https://www.rstudio.com/products/rstudio/download/preview/
是否可以执行此操作并处理多个Radix .Rmd文件?
我想做的事情的完整示例:
library(rmarkdown)
# Function to fix r() (https://github.com/r-lib/callr/issues/79#issuecomment-421103465)
render_new_session <- function(...) {
callr::r(
function(...) { suppressMessages(rmarkdown::render(...)) },
args = list(...),
show = F,
spinner = T
)
}
render_new_session("test.Rmd")
render_new_session("test1.Rmd")
render_new_session("test2.Rmd")