Skip to content
Coming soon: Ally. Your guide to the world of AI and R. Learn More →
R for the Rest of Us Logo

Tips and Tricks

From Overwhelm to Organization: Optimizing Data Workflows in R

February 20, 2025

Ever feel overwhelmed by a messy R script that's grown out of control? That's exactly what happened to Alberto Espinoza, Knowledge and Learning Manager at PEAK Grantmaking. In his job at PEAK Grantmaking, an organization that helps philanthropy to use equitable, effective grantmaking practices, Alberto supervises a Grants Management 101 class. As part of this training, Alberto has to analyze data from surveys that participants complete. With this training happening regularly, the data from it...

Report Design in R: Small Tweaks that Make a Big Difference

January 30, 2025

In August 2024, I spoke at posit::conf about doing report design in R. As I say in the talk, I never thought I'd become known for making nicely designed PDFs, but it's one thing we at R for the Rest of Us have become known for in the R world. The talk, titled Report Design in R: Small Tweaks that Make a Big Difference, was a great chance for me to share some of the things we've learned about making good reports, focusing on consistency, avoiding defaults, and incorporating brand elements like...

R Versus Python: Which One Should You Learn?

January 16, 2025

If there is one question I get asked more than any other, it's this: should I learn R or Python? Especially in recent years, many people have developed a vague sense that Python is replacing R (the rebranding of Posit from RStudio in order to serve multiple languages scared many longtime R users). But I think the discussion of whether R is declining is misguided. Because ultimately the question of R's decline is less relevant to the question of which language you should learn. More relevant...

Automate file management in R with the {fs} package

January 9, 2025

Imagine you’re working on a project, and you receive a folder filled with subfolders and files named in different styles: some in uppercase, some in lowercase, and with a mixture of spaces, dashes, and underscores. This disorganized chaos can make it hard to find anything, but the {fs} lets you quickly rename and organize everything to a consistent case and format. This guide will show you how to use {fs} to automate tedious tasks like creating, renaming, moving, and deleting files and...

Use geom_ribbon() to highlight the gap between two lines

December 19, 2024

I recently found this really nice graph in the New York Times and I thought it was really effective, particularly the fact that it shows two lines and only shows the spread over a specific period. So how can we replicate this in R, particularly the shading of the gap between existing mortgages and rates on new loans? In this guide, written with Joseph Barbier, I’ll walk you through the steps of creating a line chart with two lines, where the area between the lines is filled only for a...

Recreating Financial Times Data Viz of 2024 US Presidential Election

December 5, 2024

A couple weeks ago, in the wake of the presidential election here in the United States, everyone was looking for explanations for the results. One of the most compelling reasons that Donald Trump won came from John Burn-Murdoch. Burn-Murdoch, a columnist and the chief data reporter at the Financial Times, posted this graph showing that incumbents around the world had fared extremely poorly in 2024. This graph got a ton of attention online not only because the data that underlies it strongly...

An introduction to the {gganimate} package

November 27, 2024

The {gganimate} package is the easiest way to make animated plots in R. If you know how to make plots in ggplot, you can animate them with {gganimate}. Animated plots are a great way to capture attention, especially online where the next shiny object is just a scroll away. If you want to get attention on your data, using animation with a package like {gganimate} is a great option. In this blog post, I’ll show how to use the {gganimate} package by animating data on refugees. As part of our one...

Use vertical white lines instead of axis lines for cleaner charts

November 21, 2024

I recently came across a data viz in the New York Times that used a unique approach to adding axis lines. In this chart about the number of days that members of the United States House of Representatives served as speaker, rather than use traditional axis lines, they used white lines that show up on bars but are hidden otherwise. How can we create a bar chart in ggplot2 without using vertical white lines? This guide will walk you through the steps to create a polished bar plot using gross...

Use smart labeling in ggplot to help your audience understand your graphs

October 24, 2024

When making data viz in R, it’s easy to think that adding label to everything will make your charts easier to understand. This is rarely the case. Instead, when making charts, maps, etc with ggplot, your best bet is to label smartly. Only labeling the most important pieces of your data viz ensures that your audience will grasp what you want them to grasp. In this blog post, I’ll show you how to use smart labeling in ggplot to help your audience understand your graphs. The issue of smart...