×

Using R Markdown to Share Analysis

You have some R code that has performed some analysis. How can you share the analysis without having to spend even more time creating a slideshow or document in some other tool? Enter R Markdown, an R package that allows you to embed code snippets in Markdown documents.

Definitions

R is a statistical programming language that is often used for data analysis and visualizations. R is open source and has a very robust community that share content and ideas.

RStudio is a popular Integrated Development Environment (IDE) for R.

An R package is a group of functions created by the community that can be installed using R code or through an IDE such as R Studio.

R Markdown is a package for R and the center of this post.

Markdown is a language that uses plain text to format documents.

Getting Started

There are four easy steps to designing and publishing an R Markdown file. First, open a file with the .rmd extension. Second, write code using the R Markdown syntax. Third, add R code that generates an output to the report. Lastly, render the document into a slideshow, HTML, PDF, or Word file.

For this walkthrough, we will be using RStudio, which can be downloaded from here. If you do not have the R language installed as well, you can get that from here. In RStudio, you can install packages by clicking the Install button on the Packages window. Alternatively, you can use the following code to install a package directly.

install.packages(“rmarkdown”)

 

R Markdown Data Visualization - Download the code examples above to see the full output.

Wrap Up

R Markdown is a simple way to share R code results that includes several options for output types. The improved output allows users to understand and take action from the results quickly and efficiently. Programmers will find it easy to use and non-programmers will marvel (this is a great joke if you looked at the code examples) at the quality of your slides, document, web page, or interactive content. To learn more about R Markdown, check out the R Markdown from RStudio website and a free book, R Markdown: The Definitive Guide by Yihui Xie, J. J. Allaire, Garrett Grolemund.

We Are Hiring!

Come work with our award winning team! We are looking for mid to senior level developers for positions in both Hampton Roads and Richmond VA. Check out our careers page and send us your resume!

Brian KnoxCore Contributor
Business Analyst

Brian Knox has passed the DA-100: Analyzing Data with Microsoft Power BI exam and has been a Power BI developer, administrator, and instructor for over four years. He is a founder and leader of the Hampton Roads Power BI User Group. Brian applies his analytics knowledge as a business analyst at Marathon Consulting. He is a graduate from the College of William and Mary, having completed the inaugural class of the Master of Science in Business Analytics program. He has an undergraduate degree in Information Science from Christopher Newport University. Brian learned early on that he wanted to combine his passions of business and technology. Brian loves all things data and is always looking for ways to share his data science knowledge to help others throughout Hampton Roads.