在R标记中YAML头之前包含R块

在R标记中YAML头之前包含R块,r,r-markdown,R,R Markdown,我的Rmd文件位于不同于所需文件的文件夹中(例如style.css,logo.png,header.html) 我曾尝试将文件夹设置为工作目录,但在我可以设置它之前调用了这些文件,因此knit无法工作,因为它找不到这些文件 事实上: --- title: foo title author: foo output: html_document: includes: in_header: header.html css: style.css --- ```{r s

我的Rmd文件位于不同于所需文件的文件夹中(例如
style.css
logo.png
header.html

我曾尝试将文件夹设置为工作目录,但在我可以设置它之前调用了这些文件,因此knit无法工作,因为它找不到这些文件

事实上:

---
title: foo title
author: foo
output: 
  html_document:
    includes:
      in_header: header.html
    css: style.css

---
```{r setup, include=FALSE, echo=FALSE}
  library(knitr)
opts_knit$set(root.dir = "~/path/to/folder/")
```
正如我所希望的那样:

```{r setup, include=FALSE, echo=FALSE}
  library(knitr)
opts_knit$set(root.dir = "~/path/to/folder/")
```
---
title: foo title
author: foo
output: 
  html_document:
    includes:
      in_header: header.html
    css: style.css

---
从R脚本中,我希望使用以下方法呈现此报告:

rmarkdown::render(input = report.rmarkdown.rmd.fpath,
                  output_file = output.html.report.fpath,
                  knit_root_dir = report.working.dpath)
但我可以想象,在knit_root_dir设置的时刻,也会发生同样的事情

如果无法在YAML标题前放置块,您知道如何找到这个
header.html
style.css

我可以“手动”编写文件路径,但我的header.html如下所示:

<div><img src="logo.png" width="200px" align="right"></div>

而且无论如何都找不到logo.png,对吧

非常感谢