Tips and Tricks

How to know if your data is tidy
March 13, 2024
One of the most frequent questions we get when we teach R is “How do I know if my data is in a tidy format?” Rightfully so. Tidy data is a powerful concept and I remember asking myself the exact same questions when I first learned about tidy data. So to help you answer this question, let me give you an answer to this question that eventually helped me and made my life easier. But beware: You might find the answer a little bit unintuitive at first. Forget about tidy data Yup, that’s right....

Use tidyselect helpers to grab the right data
February 28, 2024
Tidyselect helpers are neat little helper function that help you, well, select the right data. This can make your life easier when you want to either grab many different columns or even transform many columns using across() . For example, have you ever found yourself typing out repetitive calculations like this: Here, we converted all the measurements that are given in millimeters (mm) to centimeters (cm). To do so, we had to divide the mm numbers by 10 (yay, metric system 🥳) and select all...

How to add sparklines to a {gt} table
February 14, 2024
Any table can be spiced up by adding small visual elements to it. Ideally, this makes the table more engaging and informative. One popular visual element that can get both jobs done is a sparkline . These are little line charts in a table cell that can give you a miniature overview of a time series evolution over time. Sounds complicated? It probably becomes clear when you see it in action. Here, have a look: See those little lines. They show you exactly how the open price of the stock prices...

How to work with times and dates
January 31, 2024
Time series data is everywhere. But time- and date-related data is notoriously hard to work with. But as always, the tidyverse has a nice package that makes our life just a little bit easier. In this case, it is the lubridate package that helps us. But just like time data itself, it requires a bit of effort to get used to working with lubridate . In this blog post, we go through a couple of things you might struggle with when you want to work with time data. This should help you get started...

How to create a gauge plot/speedometers in ggplot
January 17, 2024
Gauge plots are a nice way to visualize progress or parts-of-a-whole in general. Due to their round shape, they are sometimes also called speedometer plots. Here’s an example chart. It shows you how much of your goal you have already achieved. Basically, this is a round version of a parts-of-a-whole bar chart. If you want to create one of those, you can check out another one of our blog posts . In this one, we’ll show you how to create the rounded brother. Let’s dive in. The data First, we...

Getting Started with {geomtextpath}
January 3, 2024
Have you ever created a great line graph only to feel frustrated that it requires a messy, hard to read legend? What if you could label the lines directly? Even the curvy ones? And have the text follow the curvature of the lines! With the {geomtextpath} package, you can annotate your ggplot2 visualizations with clean labels and customized text annotations that can follow the shapes in your data, and it’s so much easier to get started than you’d imagine. The Basics First, let’s load our...

R for the Rest of Us 2023 Year in Review
December 20, 2023
It's been quite a year for R for the Rest of Us. With two new courses, updates to three other courses, training work with several organizations, and multiple consulting projects, we've been keeping ourselves busy! Let's share some highlights. New Courses and Updates to Existing Courses 2023 saw the release of two new courses: Making Beautiful Tables with R and Reproducibility for the Rest of Us . Created by Albert Rapp and Jenine Harris , respectively, these courses bring the total number of...

Create Parts-of-a-Whole Bar Charts
December 12, 2023
In our consulting work , we often think about what could be a better visualization for our clients. And sometimes it’s really small tweaks. One example of this is adding a gray background behind bar charts to show percentages as a part of the whole. We did this, for example, in reports about Connecticut housing . To show how to make this in R, let’s start with a bar chart that represents the results of some absolutely fictitious survey. It would be neat if we had another bar on top of each...

Speed up your coding workflow with RStudio hotkeys
November 29, 2023
RStudio is the premier tool to write R code. And just like any tool, the better you know RStudio’s features the faster you can write code. That’s why we decided show you the best hotkeys we use all the time. Don’t type the pipe Whether it is %>% or |> , it is tempting to write out the pipe letter by letter. But the pipe is such an integral part of the tidy workflow that it makes sense to give yourself a tiny speed boost whenever you use the pipe. Just hit ctrl + shift + M to get the job done....