Closed kylebutts closed 10 months ago
Documentation of the function says https://github.com/yihui/knitr/blob/50e28dab843109d5292e26695d1b486b36eec0e2/R/spin.R#L44-L47
Try using rmarkdown::render()
on the .R file directly. See documentation at https://rmarkdown.rstudio.com/docs/reference/compile_notebook.html
Thanks @cderv. I hadn't seen that in the documentation but pieced it together. Why not have the default be to use render
which seems more robust (using v2) and lets you specify output format?
I'll let @yihui answer to that.
I originally found about this function from the R Markdown Cookbook: https://bookdown.org/yihui/rmarkdown-cookbook/spin.html
This example would suggest you get a pdf document out, but you get an html
Thanks for the context, this is indeed confusing...
@yihui as anything changed since we wrote the R Markdown cookbook ?
rmarkdown::render()
on R file seems the way to spin and create the report with Rmd format. Should knitr::spin()
offer to do rmarkdown::render()
if a Rmd file with R Markdown V2 is detected ?
Otherwise, the cookbook should be updated 🤔
Why not have the default be to use
render
which seems more robust (using v2) and lets you specify output format?
@kylebutts knitr::spin()
was introduced before the rmarkdown package was born, so it uses knitr::knit2html()
instead of rmarkdown::render()
mainly for historical reasons.
This example would suggest you get a pdf document out, but you get an html
We need to clarify in the book that the R script is supposed to be rendered via rmarkdown::render()
instead of knitr::spin()
(spin()
is only an intermediate step). Thanks!
Should
knitr::spin()
offer to dormarkdown::render()
if a Rmd file with R Markdown V2 is detected ?
@cderv That's probably a good idea. Anyway, the cookbook definitely needs a bit more clarification.
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.
I recently discovered
knitr::spin
which I agree isknitr
's best hidden gem!The current version uses
knit2html
which (1) raises warning thatrmarkdown::render
should be used and (2) ignores theoutput
yaml option: https://github.com/yihui/knitr/blob/50e28dab843109d5292e26695d1b486b36eec0e2/R/spin.R#L119-L121A proposed solution that works with both
text
andhair
optionsWould you welcome a PR adding this change?
By filing an issue to this repo, I promise that
I understand that my issue may be closed if I don't fulfill my promises.