Consider the following R Markdown file in somewhere/project/paper/report.Rmd
---
title: This is in a subdirectory
output: github_document
---
```{r setup}
library(texreg)
knitr::opts_chunk$set(error = TRUE)
m <- lm(mpg ~ wt, data = mtcars)
getwd()
```
```{r knitreg}
knitreg(m)
```
```{r htmlreg}
htmlreg(m)
```
Rendering it from somewhere/project with rmarkdown::render("paper/report.Rmd", knit_root_dir = getwd()) result in errors for knitreg but not for htmlreg
This is in a subdirectory
================
``` r
library(texreg)
knitr::opts_chunk$set(error = TRUE)
m <- lm(mpg ~ wt, data = mtcars)
getwd()
```
## [1] "/somewhere/project"
``` r
knitreg(m)
```
## Warning in readLines(con, warn = FALSE): cannot open file 'report.Rmd': No such file or directory
## Error in readLines(con, warn = FALSE): cannot open the connection
``` r
htmlreg(m)
```
## <table class="texreg" style="margin: 10px auto;border-collapse: collapse;border-spacing: 0px;caption-side: bottom;color: #000000;border-top: 2px solid #000000;">
## <caption>Statistical models</caption>
##
## ... Rest of outout omitted
##
## </table>
I came across this issue while rendering a targets pipeline with tar_render(), where knitting in the file's directory is not practical.
Consider the following R Markdown file in
somewhere/project/paper/report.RmdRendering it from
somewhere/projectwithrmarkdown::render("paper/report.Rmd", knit_root_dir = getwd())result in errors forknitregbut not forhtmlregI came across this issue while rendering a targets pipeline with
tar_render(), where knitting in the file's directory is not practical.