Victor
Victor

Reputation: 9

Combining HTML CSS with Rmarkdown

On my way to becoming a datajournalist, I have come across lots of fantastic tools, such as R and Rmarkdown. Now that I work for a proper newspaper, I realize that most of the time, I end up using MS Excel (which, I don't deny, is also a great tool) and a concatenate function that I paste in an HTML file. I am losing quite a lot of my R knowledge and practice, and that's sad.

I know that I will soon be faced with a task that I would like to use as a way to get back to R and Rmarkdown.

I have some html pages working just fine and I'd like to change the data that is presented in them using Rmd.

My question is : is there a package or a way to combine into one Rmarkdown file most of an HTML page (header, css and javascript files and analytics, footer), and some Rmarkdown chunks ?

Thanks a lot for your answer.

Upvotes: 0

Views: 396

Answers (2)

Orlando Sabogal
Orlando Sabogal

Reputation: 1630

You can use .css files to style your Rmakdown. In the header you do something like:

---
title: "Habits"
output:
html_document:
  css: styles.css
---

see this

Upvotes: 1

sargas
sargas

Reputation: 558

Maybe you could try something like this (http://rmarkdown.rstudio.com/html_document_format.html#includes):

---
title: "Habits"
output:
  html_document:
    includes:
      in_header: header.html
      before_body: doc_prefix.html
      after_body: doc_suffix.html
---

This would allow the combination of html and Rmd in general. Furthermore there is the chunk option child, which would allow to use Rmd files as chunk content?

Upvotes: 1

Related Questions