Sebastian Sauer Sebastian Sauer - 3 years ago 293
Markdown Question

How to add default code snippets to blogdown posts?

I've set up my blog using blogdown.

Now I would like to define some standard code snippets that should be included in each post (e.g., for centering images). Take this R-code as an example; it should be included automatically in each post:

out.width = "70%",
fig.align = 'center'

I've read the section on templates in the blogdown book, but I could only find html based templates, which appears not so straightforward to me.

How can I add R-code snippets per default to posts using blogdown?

Answer Source

You can do this in .Rprofile, as explained in Section 1.4 of the blogdown book. The easiest way is probably to use an RStudio project, and create a .Rprofile file in the root directory of the website project, in which you set the knitr global chunk options.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download