Quantcast
Channel: r software hub
Viewing all articles
Browse latest Browse all 1015

Alternate R Markdown Templates

$
0
0

By hrbrmstr

The knitr/R markdown system is a great way to organize reports and analyses. However, the built-in ones (that come with RStudio/the rmarkdown package) rely on Bootstrap and also use jQuery. There’s nothing wrong with that, but the generated standalone HTML documents (which are a great way to distribute reports) don’t really need all that cruft and it’s fun & informative to check out new frameworks from time-to-time. Also, jQuery is a heavy crutch I’m working hard to not need anymore.

To that end, I created a package — markdowntemplates — that contains three alternate templates that you can use out of the box or (hopefully) clone, customize and use in your future work. One template is based on the Bulma CSS framework, the other is based on the Skeleton CSS framework and the last one is a super-minimal template with no formatting (i.e. it’s a good one to build on).

The github repo has screenshots of the basic formatting.

I tried to keep with the base formatting of each theme, but I went a bit crazy and showed how to have a fixed banner in the Skeleton version.

How it works

There are three directories inside inst/rmarkdown/templates each has a similar structure:

  • a resources directory with CSS (and potentially javascript)
  • a skeleton directory which holds example Rmd “skeleton” files
  • a base.html file which is the parameterized HTML template for the Rmd
  • a template.yaml file which is how RStudio/knitr knows there’s one or more R markdown templates in your package

The minimal base.html is small enough to include here:


 

 

 

 
$for(header-includes)$
$header-includes$
$endfor$
 
$if(highlightjs)$

$endif$
 
$if(highlighting-css)$

$endif$
 
$for(css)$

$endfor$
 

 

$if(title)$$title$$endif$

$for(include-before)$ $include-before$ $endfor$ $if(toc)$
$toc$
$endif$ $body$ $for(include-after)$ $include-after$ $endfor$
$if(mathjax-url)$ $endif$

I kept a bit of the RStudio template code for source code formatting, but grokking the actual template language should …read more

Source:: r-bloggers.com


Viewing all articles
Browse latest Browse all 1015

Trending Articles