Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sourcing References in rmarkdown: workaround

I am working with markdonw v2, the rmarkdown package. Throughout the .Rmd file, I create links to websites or images

[Link1][pathLink1]
![Image1][pathImage1]

then, at the end of the document I give the references

[pathLink1]:http://website.com/linkes/Link1.md 
![pathImage1]:./images_rmd/

There are other reports that talk about the same citation and use same images in different contexts. I would like to create a separate file containing all the links and path difinitions, so that I could simply source it at the end of each .Rmd file, like I would call in an R environment

source(/Rcode1.R)

Question: How do I "source" another file in .Rmd, so that the sourced code prints needed text strings into the .Rmd file?

This would offer some help with citations and scientific paper composition in HTML and PDF.

like image 231
andrey Avatar asked Sep 30 '22 11:09

andrey


1 Answers

http://yihui.name/knitr/demo/child/

```{r child, child = '~/path/to/child.Rmd'}
```

and similarly for .Rnw files:

<<child, child = '~/path/to/child.Rnw'>>=
@

And a full example: https://github.com/yihui/knitr-examples/blob/master/087-child-example.Rnw

like image 200
rawr Avatar answered Oct 03 '22 16:10

rawr