sourcing References in rmarkdown: workaround

本秂侑毒 提交于 2019-12-07 05:24:01

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/24464318/sourcing-references-in-rmarkdown-workaround

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!