In some but not all posts of a blog made with blogdown I use highcharts to create interactive charts. For this, I need:
- Include the necessary highcharts javascript sources in the relevant posts
- Load the
highcharterpackage (and alsomagrittr, as they work well together) in the relevant .Rmds
For the first point, a fairly elegant solution may be including a new param
usehighcharts: true in the params of the posts and then in the header.html partial use:
{{ if .Params.usehighcharts }}
... include the needed javascript ...
{{ end }}
But for the second point, I do not have an elegant solution, so what I do is manually include a chunk like so in the beginning of the relevant .Rmds, which I find error prone and not very elegant:
```{r echo=FALSE}
suppressPackageStartupMessages({
library(highcharter)
library(magrittr)
})
```
What would be a more elegant/best practice solution to this ?