Embed text blocks from external Word/txt-files

Hi there,

I am currently working on a use case where external text blocks/elements are supposed to be integrated into an .Rmd file. Ideally, these text blocks are curated in a separate Word or txt file and delimited/identified by unique lables, such as :

## ---- chapter 1, block 1 --------
Some text

## ---- chapter 1, block 2 --------
Some more text

I would like to integrate the text into the final report as if it would have natively been written in markdown. On top, the text must include inline code that generates output on a variable already existant in the .Rmd file, like so:

## ---- chapter 1, block 1 --------
Some text

## ---- chapter 1, block 2 --------
Some more text `r mean(x)` Some more text

Is a use case like this realizable at all? So far I tried to experiment with knitr::read_chunk()and cat(readLines('./.../text_blocks.txt'), sep = '\n'), without being able to exactly match my desired case.

I would be extremely grateful for any guidance in the matter :slight_smile:

Best,
Simon

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.