sdutky
September 26, 2022, 5:17pm
1
Using this as the last chunk:
### Appendix: Rmarkdown Code
```{r catRmd,asis=TRUE}
rmd<-read_lines("catRmd.Rmd")
cat(paste(rmd,"\n"))
Output as expected when running chunk, but knitting to either pdf or html truncates lines and prepends each with two hash marks.
See attached for details
catRmd.pdf (140.5 KB)
catRmdCode.pdf (12.3 KB)
cderv
September 28, 2022, 12:51pm
2
What are you trying to do exactly ?
Do you want to use the content of catRmd.Rmd
to inserted in another Rmd file ?
If that so, the way to do that is using child document feature
This book showcases short, practical examples of lesser-known tips and tricks to helps users get the most out of these tools. After reading this book, you will understand how R Markdown documents are transformed from plain text and how you may...
sdutky
September 28, 2022, 3:10pm
3
Given that the contents of the attached catRmdCode.pdf is copied to a file catRmd.Rmd, when catRmd.Rmd is knitted, I want the literal unknitted contents of catRmd.Rmd echoed to an appendix of the knitted document, ie either catRmd.pdf or catRmd.html.
Is there a way to do this?
I have tried
# ```{r, echo=FALSE, results='asis'}
res <- knitr::knit_child('catRmd.Rmd',
options=list(echo=TRUE,eval=FALSE),
quiet = TRUE)
cat(res, sep = '\n')
# ```
but this appears to start knitting catRmd.Rmd and fails with a duplicate chunk label error.
cderv
September 28, 2022, 6:17pm
4
Ok so I misunderstood - you want to show the content of carRmd.Rmd
without evaluating it.
This is still in the doc:
This book showcases short, practical examples of lesser-known tips and tricks to helps users get the most out of these tools. After reading this book, you will understand how R Markdown documents are transformed from plain text and how you may...
The embed
engine should be what you need
```{embed}
"catRmd.Rmd"
```
See the section in the book
sdutky
September 30, 2022, 3:20pm
5
Using embed, the lines are now not truncated. Is there any way to omit the "##" prepended to each line?
cderv
October 4, 2022, 12:18pm
6
Sorry I don't follow. This should not add ##
---
title: "Demo"
output: html_document
---
See some demo file
```{embed}
dummy.Rmd
```
which dummy.Rmd
being an example to show
---
title: dummy
output: html_document
---
Some demo content
```{r}
1 + 1
```
Rendering this I'll get
No ##
on lines.
system
Closed
October 25, 2022, 12:19pm
7
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.