yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.36k stars 873 forks source link

Add an API for reading a single chunk from an external document #2270

Closed multimeric closed 11 months ago

multimeric commented 11 months ago

This question has been asked many times on StackOverflow:

In each case, the best or only solution is to use a hack like converting Rmd to R using knitr::purl, and then convert back to a chunk using knitr::read_chunk. This doesn't seem like an ideal solution, because firstly we're doing all this redundant conversion when we already have the chunk in the right format, it's just in the wrong place. Secondly, it requires the use of temporary files which it ideally would not, especially because we have to clean them up.

I wonder if we could simply have a function like knitr::read_rmd_chunk(file="foo.Rmd", chunk_name="bar-chunk") that would act like knitr::read_chunk in that it registers the chunk for use?


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.

cderv commented 11 months ago

I think this is a duplicated of

Will track this in there if you're ok.

cderv commented 11 months ago

Duplicate of #2041

github-actions[bot] commented 5 months ago

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.