2

我是目标生态系统的新手。我无法从我的目标管道创建蒸馏文章,尽管当我将输出设置为html_documentyaml 时它可以工作。我试过谷歌搜索,但找不到任何有用的东西。任何帮助,将不胜感激。

我的 RStudio 是 1.4.1717 版。运行时收到此错误消息tar_make()

Error: callr subprocess failed: Distill 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/

Visit https://books.ropensci.org/targets/debugging.html for debugging advice.
Run `rlang::last_error()` to see where the error occurred.

这是一个最小的代码示例。

代码在_targets.R

library(targets)
library(tarchetypes)

tar_plan(
  tar_target(dat, iris),
  tar_render(test_report, "test.Rmd")
)

这是我的 Rmd 文件的内容。其中大部分来自模板。

---
title: "Test"
description: |
  A new article created using the Distill format.
author:
  - name: Nora Jones 
    url: https://example.com/norajones
    affiliation: Spacely Sprockets
    affiliation_url: https://example.com/spacelysprokets
date: "`r Sys.Date()`"
output: distill::distill_article
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

```{r load-targets, include=FALSE}
tar_load(dat)
```

```{r}
summary(dat)
```

会话信息

R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] igraph_1.2.6      rstudioapi_0.13   knitr_1.33        magrittr_2.0.1    tidyselect_1.1.1 
 [6] R6_2.5.1          rlang_0.4.11      fansi_0.5.0       tools_4.1.0       targets_0.7.0    
[11] data.table_1.14.0 xfun_0.25         utf8_1.2.2        cli_3.0.1         withr_2.4.2      
[16] ellipsis_0.3.2    yaml_2.2.1        digest_0.6.27     tibble_3.1.3      lifecycle_1.0.0  
[21] crayon_1.4.1      processx_3.5.2    purrr_0.3.4       callr_3.7.0       vctrs_0.3.8      
[26] ps_1.6.0          codetools_0.2-18  glue_1.4.2        compiler_4.1.0    pillar_1.6.2     
[31] pkgconfig_2.0.3  
4

1 回答 1

1

我一直有同样的问题。

这里您可以看到distill首先通过尝试(失败)然后通过查找名为“RSTUDIO_VERSION”的环境变量来检查版本rstudioapi,该环境变量在我的系统上不存在。当这失败时,它使用默认值 1.1,它无法通过至少版本 1.2.7 的检查...

有一个简单的解决方案,如果有点 hacky,就是手动设置在distill脚本顶部寻找的环境变量。即,您的 Rmd 文件将变为:

---
title: "Test"
description: |
  A new article created using the Distill format.
author:
  - name: Nora Jones 
    url: https://example.com/norajones
    affiliation: Spacely Sprockets
    affiliation_url: https://example.com/spacelysprokets
date: "`r Sys.Date()`"
output: distill::distill_article
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
# Add environment variable
Sys.setenv("RSTUDIO_VERSION" = '1.4.1725')
```

```{r load-targets, include=FALSE}
tar_load(dat)
```

```{r}
summary(dat)
```

这对我来说完全没问题。如果您担心这会持续产生影响,您可以在之后将其删除 ( Sys.unsetenv("RSTUDIO_VERSION"))

于 2021-08-30T23:18:17.980 回答