How to Make Your Own HR Analytics Reporting Template using R and RMarkdown
Today I want to give you a very basic HR analytics reporting template in RMarkdown. As a reminder, R Markdown (Rmd) files provide a convenient way to combine analysis
and communication in a single file.
As a reminder, RMarkdown (Rmd) files provide a convenient way to combine analysis and communication in a single file.
The purpose of this template is to get you up and running with reproducible analytics quickly so you can craft your own custom report templates over time.
Read through the principles and procedures below.
Keep what you like, ditch what you don’t.
Remember, there is nothing set in stone so be sure to shape this template according to your own needs.
How to Use the Template
Step 1: Download the Template
I’m providing it here as a text file because WordPress get cranky with Rmd files. Just open the text file, copy all of the content, and then past it into a new Rmd document in RStudio.
Step 2: Download the Demo Data
Step 3: Create a new Rmd file in RStudio and replace the content with the copied text file content.
….or you can just open the text file and save it as an Rmd file.
Your Starting Point
As a preview, the initial report will look like this and includes key headers and a floating table of contents:
I’ve included lots of comments in the code to give you some pointers so you know what is happening and some things that you might want to change when you adopt this template for your own use.
Principles
Give them only what they need
- Use tables and figures; keep text to a minimum
- Give the bottom line up front; they’ll dive in if they care
- Rule of thumb: Assume they will only give your brilliant report 20 secs unless compelled to read on
Make it reproducible
- Start with clear, stable canonical data sources
- Do all the data manipulation within the Rmd document itself (at least when you first get startout)
- Avoid ad-hoc scripting outside of the document
Go in order
- Put your libraries and your data loading at the top.
- Run the basic descriptives first so people get a feel for the big picture
- Start with the basic relationships and then expand only as needed
Break it down by the big ones
- Demographics (M/F, age, D&I)
- Areas, roles
- Movement (read: people in, people out, people up, people over)
- Changes over time (e.g. engagement, turnover, expenses, revenue)
Procedures
Look for all of these procedures/ methods in the template file.
1. Label your code chunks
- Give every chunk a clear name such as
{r load_libraries}
or{r turnover_by_role}
2. Use comments liberally
- Use the
#
symbol at the at the start of lines within your code chunks to describe what you are doing - Think of these comments as a gift to your future self. Trust me.
3. Write headers with the reader in mind
4. Use pipes where possible
- I speak of the piping
%>%
function from magrittr together with the dplyr functions - This will help make your code more readable and interpretable later
Summary
Templates save you time and increase your impact by making your work scalable and reproducible: you know where the numbers came from, you can share the results, and you can do it again.
Moreover, it means conserving cognitive energy by shifting mental work and decision-making from the basic steps to the harder, and far more interesting, work of data analysis and interpretation.
Thanks again for reading HRAnalytics101!
Please leave your comments and suggestions. I would especially welcome comments on anything you might add to your own HR analytics reporting template.
Other Resources
You can find lots of ideas and examples for Rmd templates in this Rmd gallery from RStudio
Contact Us
- © 2023 HR Analytics 101
- Privacy Policy