I work in a project folder, to say that its absolute path: /project. getwd()tells me that I am in this project folder. All my reads and writes of files belong to this root of the project. /projecthas a subfolder /project/docs/In which there is an R Mardown file and an R script:
report.Rmd contains:
```{r }
plot(cars)
```
And knit_reports.Rcontains:
library(knitr)
knit2html("./docs/report.Rmd", "./docs/report.html")
If I run knit_reports.R, an html page is created, but the numbers do not appear on the page.
The problem is that the numbers are stored in /project/figures. They are not visible for generating an html document. I am looking for a way to tell knitr to store images under /project/docs/figuresinstead.
knitr root.dir base.dir report.Rmd , opts_knit$set(root.dir = "./docs") opts_knit$set(base.dir = "/project/docs").
, /project/docs:
setwd("./docs/")
knit2html("report.Rmd", "report.html")
A /project/docs/figure, html.
, setwd() script, . knitr setwd()?