gpt4 book ai didi

r - 无法在 RStudio knitr 中使用修改后的单词模板

转载 作者:行者123 更新时间:2023-12-04 12:02:10 25 4
gpt4 key购买 nike

无法使用来自 Rstudio 的 Knit Word 使用来自 Rstudio 的修改后的 Word 模板。本周安装并更新了 Rstudio 和所需的软件包。运行 OS X 10.10.5 并使用 Word 2011。简化了对 Yihui Xie 的 113-externalization.rmd 和 113-foo.R 的测试,并关注了他的 Vimeo 视频 https://vimeo.com/110804387关于这个问题。在所有情况下,编织 RMD 文件都使用默认格式,而不是存储为 template.docx 的修改后的模板。我已尝试将副本放入项目目录中的所有位置,但均未成功。

#113-externalization.Rmd
---
title: "Untitled"
output:
word_document:
reference_doc: "template.docx"
---

# Code Externalization

```{r cache=FALSE}
knitr::read_chunk('113-foo.R')
```

The following two chunks are from the external R script `113-foo.R`:

```{r test-a}
```
```{r test-b}
```
#code for 113-foo.R
# ---- test-a ----
1 + 1
x = rnorm(10)

# ---- test-b ----
mean(x)
sd(x)

搜索发现 Changing word template for knitr in Rmarkdown , 但未能在项目目录中的任何位置找到修改后的模板。

最佳答案

很确定 YAML header 的缩进是问题所在。将其更改为:

---
title: "Untitled"
output:
word_document:
reference_docx: "template.docx"
---

我自己也刚刚发现,使用 reference_docreference_docx 并没有什么不同。

关于r - 无法在 RStudio knitr 中使用修改后的单词模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39598365/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com