Skip to content
R for the Rest of Us Logo

Blog

Learn to use the most powerful tool for working with data.
Even if you've never coded before.

Data viz tips for parameterized reporting: set consistent axis limits

August 1, 2024

One of the biggest challenges we face when doing parameterized is how to make plots consistent across multiple reports. We’ve learned (oftentimes the hard way) many tricks for dealing with this problem. One I want to share with you today is making your axis limits consistent when making multiple plots. Here’s an example of a plot that shows median income by county for the annual Oregon by the Numbers . Let me show you a simplified version of the function I created to make these plots. We’ll...

How to make polished population pyramids in ggplot: part 2

July 18, 2024

I wrote recently about how I revamped the process of making population pyramids for Oregon by the Numbers , the report I’ve worked on for the last several years. Rather than making one plot, I used the patchwork package to stitch together three parts: A plot for women on the left Age labels in the center A plot for men on the right The result is a polished version of a population pyramid that I’m quite pleased with. The blog post I wrote about making this version of the population pyramid saw...

Animated versions of common dplyr functions

July 17, 2024

One of the best parts about the functions in the dplyr package (one of several that make up the tidyverse collection of packages) is that their names indicate what they do. No need to remember a weird acronym; the name of the function to filter your data is filter() . But, helpful as these function names are, it can still be hard to remember exactly what the functions do. In remaking my Fundamentals of R course in 2023, I had Albert Rapp generate animated versions of the most common...

How to make polished population pyramids in ggplot: part 1

July 11, 2024

How do you make a population pyramid in ggplot2 ? These charts, which allow us to see the distribution of the population by gender and age, are common ways to examine demographics in a particular place. The ggplot code needed to make a population pyramid is quite straightforward, but, as you’ll see in this blog post, you can go way beyond straightforward to make a polished population pyramid (try saying that three times fast!). I’ve made hundreds of population pyramids for the last few years...

What's New in R

A weekly roundup of new resources in the world of R.

What’s New in R: September 16, 2024

September 16, 2024

Welcome to this week’s edition of ​What’s New in R ​! This week, we’re featuring a tutorial on making musical chords in R, a worthy collection of short R commands and tricks, and a tutorial on adding hillshade effects to your maps. Let’s dive in! Listening to complex tones using sine waves and toneR Did you know R could create musical chords? It can! In this post, Matt Crump uses the {toneR} package to make chords. Pretty cool! Read More → A worthy collection of short R commands and tricks...

What’s New in R: September 9, 2024

September 9, 2024

Welcome to this week’s edition of ​What’s New in R ​! This week, we’re featuring impressions of Positron, a package for translating text, and a video on using GitHub Actions to publish a Quarto project automatically. Let’s dive in! Positron IDE - A new IDE for data science You may have heard about the new IDE (integrated development environment) for editing R code called Positron . Made by the folks at Posit, it’s a new alternative to RStudio. In this blog post, Athanasia Mo Mowinckel talks...

What’s New in R: September 3, 2024

September 3, 2024

Welcome to this week’s edition of ​What’s New in R ​! This week, we’re featuring the second edition of a ggplot book, a tutorial on making multi-column tables, and a warning about AI slop websites offering R advice. Let’s dive in! R Graphics Cookbook, 2nd edition The 2nd edition of this book by Winston Chang was released earlier this year. It’s got recipes that show you how to make a wide variety of charts in ggplot. It’s a great reference. Read More → Transform data for easier multi-column...

What’s New in R: August 26, 2024

August 26, 2024

Welcome to this week’s edition of ​​What’s New in R​ ​! This week, we’re featuring a website that collects all Quarto extensions, a package that helps you to convert between output formats, and a tutorial on how to make a map that shows traffic noise. Let’s dive in! Quarto extensions Quarto extensions are a way of adding functionality to the base set of tools that exists in Quarto. For example, I used the spotlight extension to be able to highlight sections of my slides ( like this ) that I...

R in 2 Minutes

Short videos highlighting useful R packages and functions.

How to preview plots at specific dimensions in RStudio

September 12, 2024

If you've ever saved plots made in ggplot to a file, you've probably noticed that the dimensions of your plots you saw in RStudio does not correspond to their dimensions outside of RStudio. I recently learned a tip from Nicola Rennie for how to deal with this. Using the ggrecord() function from the camcorder package, you can preview plots in RStudio so that they have the exact same dimensions as when you save them with ggsave() .

How to wrap text automatically in ggplot

August 15, 2024

If you've ever spent time in ggplot trying to get the width of text elements just right, this tip is for you! I recently learned from Nicola Rennie about the element_textbox_simple() function from the ggtext package. This function will automatically wrap your title, subtitle, or other text so that it fits perfectly with your plot.

How to use RStudio's autocomplete feature to easily import data

July 2, 2024

Have you ever started writing code to import data, only to forget what the file you want to import is called? You've got to go find the file, remember its name, and then put into your code. There's a quicker way! In this video, I show how to use RStudio's autocomplete function in order to easily import your data.

Make your code output easier to see in RStudio

June 20, 2024

When I live code, it's often the little things that I do that people are most interested in. I was recently doing some live coding and someone asked how I changed where the output of my code showed up when working in a Quarto document. Here's a short video to show you how to change your code chunk output to show up in your console when working in RStudio.

Podcast

Conversations with users around the world about interesting things they are doing with R.

R for the Rest of Us Podcast Episode 18: Miles McBain

August 29, 2024

In this episode, I speak with Miles McBain, a data scientist and R package developer from Brisbane, Australia, about patterns and anti-patterns in data analysis reuse. Miles shares his journey from a generalist software developer to a data science specialist, his passion for R, and the evolution of his coding practices. We delve into the intricacies of code reuse in data analysis, discussing common pitfalls to avoid, the benefits of creating reusable code packages, the process of breaking...

R for the Rest of Us Podcast Episode 17: Meghan Harris

July 25, 2024

In this episode, I speak with Meghan Harris, a data scientist at the Prostate Cancer Trials Consortium at the Memorial Sloan Kettering Cancer Center. Meghan is one of the special people who do generative art in R. She talks about why she likes making generative art in R and how it has helped her improve her R skills in other areas. Listen to the Audio Version Watch the Video Version You can also watch the conversation on YouTube. In the video version, Meghan gives a walkthrough of how to make...

R for the Rest of Us Podcast Episode 16: Cara Thompson

June 13, 2024

In this episode, I speak with Cara Thompson about color, delving into several aspects of its use in data visualization. Cara is a UK-based data visualization consultant with over 15 years of experience in transforming data insights into clear, compelling visual stories. We explore how she finds inspiration for selecting colors, her reasons for not simply using organizations' brand colors in her visualizations, and the importance of dedicating time to thoughtfully consider color choices in...

R for the Rest of Us Podcast Episode 15: Nicola Rennie

May 15, 2024

In this episode, I talk with Nicola Rennie about making data viz for mobile devices. Nicola is a lecturer in health data science based within the Center for Health Informatics, Computing, and Statistics at Lancaster University in the UK. She recounts her initial encounter with R and how she got deeper into data visualization in R as a means of creative expression. Amidst the plethora of programming languages available, Nicola sheds light on why she chose R specifically for data visualization....