Skip to content
R for the Rest of Us Logo

R for the Rest of Us Blog

How to make heatmaps with R using ggplot2 and leaflet

We're often asked by clients to make maps, and oftentimes they ask us to make heatmaps. For example, we made heatmaps with {ggplot2} in these reports on 2020 U.S. Census outreach efforts . And we made interactive heatmaps with the {leaflet} package in this map for the Asian Pacific Islander Council . Also known as choropleth maps, heatmaps are incredibly useful and easy to understand maps. At their simplest, heatmaps require two things: Shapefiles for the regions of interest. Your regions...

Why R is Magic

A couple weeks ago, I had the opportunity to speak to some folks at Western Michigan University. I called my talk Why R is Magic. Because, well, it is. I busted out my favorite R party trick: doing a survey and immediately generating a report with RMarkdown . I even tried something new by sending out the reports to people by email using the gmailr package . (Yes, you can send email from R. Did you now know that it’s magic?) The folks at the Western Michigan Evaluation Center were kind enough...

What the heck does `summarise()` ungrouping output (override with `.groups` argument) mean?

Ever been using R and gotten this message? summarise() ungrouping output (override with .groups argument) What the heck does it mean? This is not an error. It’s just R’s way (the dplyr package specifically) of telling you what is happening with your data. Here’s a quick explanation of what this message is all about and how to avoid it. Hope that helps! Just a heads up that newer versions of the dplyr package dropped this behavior. So if you never see the summarise() ungrouping output...

How To Make Data Viz That Matches Your Organization's Branding

Here at R for the Rest of Us, we make a lot of reports for clients . And one of the most important things we do in these reports is use the clients' colors throughout. Picking a color scheme that ties in with a client's brand or that evokes the subject matter behind the data is what allows the plot to contribute to, rather than detract from, the main story the client is seeking to tell. It's what we've done for the last several years working on Oregon by the Numbers . The report uses the...

A Chat About Tidy Data

Tidy data is one of the most complex concepts for participants in R in 3 Months . Even before they get to the actual coding involved in data tidying, many struggle with what tidy data is exactly. I introduce tidy data to R in 3 Months participants through this lesson (which comes from the Going Deeper with R course ). In it, I try to give an overview of what tidy data is and why it's beneficial to use it. But, for many people, this isn't enough. Understanding tidy data takes several weeks —...

2021 Year in Review

As 2021 comes to a close, I wanted to share what R for the Rest of Us has been up to this year. It's been a busy year and just trying to remember everything we did has been a challenge! You'll notice first of all that I said we. I've always used I when referring to the business because, before 2021, it was pretty much just me running R for the Rest of Us. In the beginning of the year, I decided it was time to bring on others to help me. Throughout the year, I've worked with others on courses,...

I've Hit My Enough Number

A couple years ago, I read Paul Jarvis's book Company of One . The book argues that the idea of growth for its own sake is often misguided. Instead, businesses should grow at a speed that fits with the work and personal goals of their owners. I loved the whole book, but one idea has really stayed with me as a business owner: the need to define an enough number . Rather than constantly seeking more revenue, define what you're working toward and stop when you get there. 2021 has been a very...

How to Create Multicolumn Layouts in RMarkdown

In a lot of the consulting work that R for the Rest of Us does , we do complex layouts of the sort are typically done with page layout software like Adobe InDesign. For example, in the reports we did on demographic and housing data in Connecticut , the charts were laid out in a complex grid across multiple pages. Or take a look at these reports , done in partnership with the Democracy Funders Collaborative's Census Subgroup and ORS Impact , that provide an overview of efforts to promote the...

How to Make a Diverging Bar Chart in R

Much of the credit for this blog post goes to Thomas Vroylandt . Before we began working together regularly , I made diverging bar charts but never really understood how things worked. Thomas has helped me truly understand how to make these visualizations. In a previous life, I worked in the world of program evaluation . In this work, I did a lot of surveys. And in these surveys, we often used Likert scales for answer options. For example: Question: How good is the education at your school?...

How to Set Your Default Package Install Location in R

One problem that people often have, especially when they work on Windows network drives, is that they can't install packages. This typically happens because they don't have admin rights on their computer and by default R tries to install packages into a location that requires admin rights. To see where your packages are installed to by default, type .libPaths() in the console and hit enter. If you use a Windows network drive, you may see something like this: This shows two paths: The first...