Rmarkdown animated GitHub corner

August 16, 2019
By

[This article was first published on Posts | Joshua Cook, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This is an incredibly easy way to spice up any Rmarkdown file. It adds an animated link to GitHub in the top corner of the HTML output, just like you see at the top of this page. Mouse over the icon to make it wave. All thanks and praise should go to the creator Tim Holman.

The first step is to create a new file called “header.html” and paste in the following code (alternatively, you can right-click here, download this file, and place it in the same directory as the Rmarkdown). This creates a blue icon, though the background color and GitHub figure color can be changed at style="fill:#1E80F0; color:#fff, in that order. You’ll also want to change the link URL at the very begining of the code: href="https://github.com/jhrcook"


Then, in the YAML header of the Rmarkdown, tell it to inlcude the new file at the beginning of the output HTML.

---
title: "Title of Rmarkdown"
author: Joshua Cook
date: 2019-08-16
output:
html_document:
includes:
in_header: header.html
---

That’s it! It is really that simple to use.

NB. If there is navigation bar at the top of the HTML file (if you are using ‘pkgdown’, for instance), you will need to adjust the top position of the GitHub corner, manually. This can be done by adjusting the values in position: absolute; top: 0; border: 0; right: 0;, where a positive value for top will move the corner down.

To leave a comment for the author, please follow the link and comment on their blog: Posts | Joshua Cook.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)