Site icon R-bloggers

Display Pretty R tables in GitHub

[This article was first published on Blog - Little Miss Data, 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.

One thing I love about performing analysis in .Rmd (R Markdown) files is how easy it is to share your results publicly on GitHub. Create your analysis in the .Rmd file, set your output variant as below, knit to .md format and then add your files to GitHub!

 
 

The Problem

There is only one problem with the .md output: PRETTY TABLES! Most of the pretty tables packages that I like to use, or don’t display all of the formatting, or don’t display at all in .md format.

The Solution

Fear not, this is very easily solved by simply changing your output to html and setting up GitHub pages on your GitHub repo.

The Example

Step 1: Create your .Rmd files with your pretty tables and set the output to html_document as per below.

The example full .Rmd file can be found here. The final webpage with pretty R tables can be found here.

 
 

Step 2: Knit to HTML

This is a pretty easy task. Simply hit the “Knit” button in the top menu within RStudio. See the video below for a demo.

  

Step 3: Create a Repo and add your .Rmd and .html files

Next, create a GitHub repo and add your html file. Follow the steps below or watch the demo for instructions.

  

Step 4: Publish your HTML as a GitHub Page

Next, enable GitHub pages on your repo and gather your new page link. Follow the steps below or watch the demo for instructions.

  

Optional: Change your `README.md` file to link to your html page

You may want to change your README.md file to direct your readers to your html page. Simply edit the README and add a link to the GitHub pages URL.

 

THANK YOU

Thank you for reading about how to host your pretty R tables in GitHub. Please remember that the full .Rmd file can be found here. The final webpage with pretty R tables can be found here.

Please reach out to me on twitter to let me know if you like the package and share your findings.

 

To leave a comment for the author, please follow the link and comment on their blog: Blog - Little Miss Data.

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.