Can't correctly call knit2html in by pasting code from an Rmd file

Today, my RTutor problem sets hosted on an account suddenly failed with a strange error. I was able to track back the error to the following issue that I filed on the knitr Github page:

I just wanted to cross-reference the issue here, since I only encountered the problem on the, not on my local desktop. So I am not sure whether it is more of a knitr or a issue.

I am unable to reproduce the issue you describe. I made my attempt public, so please verify it represents what you are doing as well.

1 Like

It is not reproducible to me, either.

1 Like

Sorry, forgot that the default option of a cloud project is private and didn't originally make it cloud public. You should now be able to access it under:

I meant something different than in Josh's example. If you open in my project the file knitr_test.Rmd and select all the code inside the first chunk and then press Ctrl-Enter to run that code in the R console, an error arises in the call to knitr::knit2html and the knitr chunk options are not set correctly. Yet, if you select the same code in the R file knitr_test.R and press Ctrl-Enter, it runs without error.

Admittedly, it is not a common use case to call knit2html by manually running some Rmd chunk. However, that is the standard setting (so far) for developing an RTutor problem set, like the file prevalance_sol.Rmd in that project. One runs the code inside the first chunk to create and show the problem set. Yet, the command and call at some point knit2html and now fail. It works however, if I run the same code from an R file.

I just found this behavior very strange. Why does it matter whether I run code from an .Rmd file in the R console or from an R file in the R console? Shouldn't it just execute the code in the same way? I encountered this issue only on rstudio cloud

Following here -- I haven't done quite the deep dive that skranz has but it does indeed seem to be a weird issue that shouldn't be occurring.