Reputation: 1817
I have a simple Rmarkdown file:
---
title: "My R Markdown Example"
output: html_document
---
library(texreg)
model <- lm(mpg ~ cyl, data = mtcars)
knitreg(list(model), caption = "knitreg")
However whenever I try to knit
using knitreg
I get a readlines error. The code runs normally and other commands like htmlreg
work correctly.
Error in `readLines()`:
! cannot open the connection
Backtrace:
1. texreg::knitreg(list(model), caption = "knitreg")
2. rmarkdown::all_output_formats(knitr::current_input())
3. rmarkdown:::enumerate_output_formats(input, output_yaml = output_yaml)
4. rmarkdown:::read_utf8(input)
5. base::readLines(con, warn = FALSE)
Execution halted
There seems to be some attention brought to the issue here: https://github.com/leifeld/texreg/issues/197
Upvotes: 1
Views: 50
Reputation: 1817
Here is a hacky solution that does the job for now.
if (knitr::is_html_output()) {
knitreg. = texreg::htmlreg
} else {
knitreg. = texreg::knitreg
}
Upvotes: 1