I encountered a very strange bug when using knitr::knit2html on the rstudio.cloud. It took me quite some time to get to the core of the problem in a simple example. But here it is.
There is the R file knitr_test.R with the following code:
library(knitr)
txt="```{r 'test_chunk'}\n1+1\n```"html=knitr::knit2html(text=txt,fragment.only=TRUE, quiet=TRUE)
html# No error because default chunk options are there in the R fileknitr::opts_chunk$get()
The call to knit2html works perfectly fine there. The strange thing is that I have the same code in a chunk in the Rmd file knitr_test.Rmd. When I run the code there, knit2html stops with an error
Quitting from lines 2-3 ()
Error in Encoding(x) : a character vector argument expected
So for some strange reason default options don't seem to be set if knit2html
is called from an Rmd file on rstudio.cloud.
On my local windows desktop I don't have the problem.
All default options are also set when called from an .Rmd chunk.
If you don't know how to fix it (or it is a difficult shiny cloud issue),
do you perhaps know a simple workaround to set the default knitr options manually?
Best wishes,
Sebastian
The text was updated successfully, but these errors were encountered:
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.
Dear Yihui,
I encountered a very strange bug when using
knitr::knit2htmlon therstudio.cloud. It took me quite some time to get to the core of the problem in a simple example. But here it is.In the following rstudio.cloud project
https://rstudio.cloud/project/46324
There is the R file
knitr_test.Rwith the following code:The call to
knit2htmlworks perfectly fine there. The strange thing is that I have the same code in a chunk in the Rmd fileknitr_test.Rmd. When I run the code there,knit2htmlstops with an errortraceback()then showsFurther investigation with the debugger shows that
options$fig.pathis set toNULL. Inside the Rmd file I get the following chunk options:Yet running the same line in the R file, I get, a lot of default options:
So for some strange reason default options don't seem to be set if knit2html
is called from an Rmd file on rstudio.cloud.
On my local windows desktop I don't have the problem.
All default options are also set when called from an .Rmd chunk.
If you don't know how to fix it (or it is a difficult shiny cloud issue),
do you perhaps know a simple workaround to set the default knitr options manually?
Best wishes,
Sebastian
The text was updated successfully, but these errors were encountered: