如何使用夸托获取()外部R脚本?

qv7cva1a  于 2023-02-06  发布在  其他
关注(0)|答案(2)|浏览(100)

我正在试用Quarto并将我的Rmarkdown文件"转换"成一个四开文档。在我的旧Rmarkdown文件中,我会使用source("R_datacleaning.R")source("R_Functions.R")来运行数据清理和加载一些函数。我也试过source(here("R_Functions.R")),但它也不起作用。R-scripts和qmd文件在同一个目录中。
我似乎不能让它在. qmd中工作。我得到的错误是Error: RStudio not running。我四处搜索并查看了Quarto文档,但没有找到任何与此相关的内容。我想可能有一些关于RStudio中的Quarto环境我不理解的地方。希望得到任何帮助,谢谢!
编辑:

---
title: "quarto_test2"
format: html
---

```{r}
library(here)

source(here("R_Functions.R"))

错误消息为:

processing file: quarto_test2.qmd
|.......... | 14%
ordinary text without R code

|.................... | 29%
label: unnamed-chunk-1
Quitting from lines 7-10 (quarto_test2.qmd)
Error: RStudio not running

Execution halted


`R_Functions.R`与`quarto_test2.qmd`位于同一目录中,如前所述。

* * 版本信息**
* RStudio版本为`2022.07.2`。
* R版本`4.2.0`。
* 四开版本`1.1.245`。
3j86kqsm

3j86kqsm1#

我在pdf中获得成功

---
title: "source() external R script in Quarto, in PDF"
format: 
  pdf:
    toc: true # table of contents
---

一些短信...

```{r}
#| echo: true
#| eval: false # skip evaluation
#| file: C:/directory/script.R

一些短信...
balp4ylt

balp4ylt2#

在经历了许多类似的挫折之后,我发现了这一点:https://github.com/rstudio/rstudio/issues/11361
基本上可以添加到您的设置中:

project:
     execute-dir: project

相关问题