Site icon R-bloggers

ggradar: radar plots with ggplot in R

[This article was first published on business-science.io, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Businesses have tons of data. But 90% have no clue how to use it. Here’s what they are overlooking…

Within-Group Analysis. Groups are important (think customer segments). But group-wise comparisons can be tricky. Thankfully an R package exists to help us compare within groups using a visualization called a Radar Plot.

What R package is it? It’s called ggradar. And I want to share it with you so you can do business comparisons (like customers with RFM Analysis) in under 10-minutes. Here’s what you learn in this R-Tip:

  1. How to use Radar Plots in Business (Customer Segments, Avatars, & RFM Analysis)
  2. How to make Radar plots with ggradar
  3. BONUS: How to sort the radar plots using similarity (important for identifying similar customers and products)

R-Tips Weekly

This article is part of R-Tips Weekly, a weekly video tutorial that shows you step-by-step how to do common R coding tasks.

Here are the links to get set up. 👇

This Tutorial Is Available In Video

I have a companion video tutorial that shows even more secrets (plus mistakes to avoid). And, I’m finding that a lot of my students prefer the dialogue that goes along with coding. So check out this video to see me running the code in this tutorial. 👇

What Do I Make In This R-Tip?

By the end of this R-Tip, you’ll make this radar plot comparing multiple products. Perfect for impressing your boss and coworkers! (Nice Plotting skills)

Don’t forget to get the code.

Thank You Developers.

Before we dive into ggradar, I want to take a moment to thank the data scientist and developer of ggradar, Ricardo Bion. Thank you for making this great R package!

Why Use Radar Plots For Business?

In business, we need a way to visually compare multiple things like customer segments (or customer avatars). Here’s why…

RFM Analysis, Customer Segments & Customer Avatars.

One of the things I do when analyzing customers is to compare them by different measures like frequency of purchases, monetary value purchased in past year, time since last purchase.

Why do I bring up RFM Analysis, Customer Segments, and Customer Avatars?

Well, it’s the perfect thing for a radar chart.

Example. Weight-Loss Supplement Company

Here’s an example of how a business can use a radar plot for RFM Analysis. This hypothetical company sells weight loss supplements. What can you see from the radar plot?

Example of a radar plot for a company that sells weight-loss products
(Useful for customer avatars, customer segments, & RFM Analysis)

We can visually see that “Young Bodybuilders” are our target market. They are making lots of purchases and possibly taking the supplements to cut weight before a competition.

We can also see that “Middle-Aged Athletes” seem to be a newer market or possibly had more recent sales demand due to promotions. However they seem to spend less money and less frequency than the other customers (the average).

Radar plots can help us visualize within-group analysis

The brilliant thing is that radar plots are a powerful way to visualize our customer groups. And they work really well for this task.

Ok, now that we know what a radar plot is and why it’s useful for business analysis, now we need to help you understand how to visualize data. To help, I want to get you set up with data visualization guidance (using the premier data visualization library in R).

To help you learn data visualization faster, you’re going to need…

My Cheat Sheet For My Top 100 R Packages

The next thing you’re going to need is to have access to all of the R packages that I use regularly in my data analysis projects.

Why?

Even I forget which R packages to use from time to time. And this cheat sheet saves me so much time. Instead of googling to filter through 20,000 R packages to find a needle in a haystack. I keep my cheat sheet handy so I know which to use and when to use them. Seriously. This cheat sheet is my bible.

Once you download it, head to page 1 and you’ll see the ggplot2 package I use for Data Visualization.

Beyond ggplot2, you’ll be able to learn even more R packages. You get 100 R packages broken down by category, which is important when you want to work in these fields:

So steal my cheat sheet. It will save you a ton of time.

Tutorial: Radar Plots with ggradar

I want to show off how quickly you can make radar plots in this tutorial with the ggradar package, which extends ggplot2 for radar plots. I’ve seen tutorials in Python where it takes 50 to 100 lines of code with matplotlib. So ggradar is a massive productivity enhancer. We’ll make some awesome radar plots in 1 line of code.

Making radar plots for within-group analysis (e.g. comparing customer segments)

I’m constantly doing within-group analysis. So that’s what I’m focusing on here. In the YouTube Video I show off the correlation and similarity which can help you find similar groups within your data.

Step 1: Load the libraries and data

To get set up, all we need to do is load the following libraries and data.

Get the code.

We’ll use the mpg dataset, which has data on 234 vehicle models.

With data in hand, we are ready to create the automatic EDA report. Let’s explore!

Step 2: Data Wrangling

We’re going to do within-group analysis. So we just need to summarize by group.

Get the code.

This produces the within-group data that has been rescaled and is ready for ggradar

Step 3. Make a Radar Plot

Radar plots make within-group analysis a visual experience.

Simple Radar Plot

Making a radar plot is as simple as 1 line of code.

Get the code.

Here’s the default data visualization. It’s not going to win any data-viz awards, but we’re on the right track.

Customizing the Simple Radar Plot

With just a few tweaks, I can upgrade my within-group analysis and begin to get some business insights.

Get the code.

…which produces this data visualization.

Great, now I can see that there are key business insights based on their similarities:

Next, I want to break these out so I can really expose their trends.

Faceted Radar

The faceted radar plot is a bit more code because of the formatting. Again, I recommend using the ggplot2 links in my R Cheat Sheet… These are a savior for remembering the ggplot theme options.

Get the code.

…which produces this data visualization

BONUS: Ordering The Faceted Radar Plot By Similarity

As a YouTube Bonus, I show you how to order the faceted radar plot by the similarity of groups. Ordering by similarity makes it much easier to compare groups in the data. Here are the links to reproduce:

I can now see that:

Conclusion

You learned how to use the ggradar library to make radar plots. Great work! But, there’s a lot more to becoming a data scientist.

If you’d like to become a data scientist (and have an awesome career, improve your quality of life, enjoy your job, and all the fun that comes along), then I can help with that.

Step 1: Watch My Free 40-Minute Webinar

Learning data science on your own is hard. I know because IT TOOK ME 5-YEARS to feel confident.

AND, I don’t want it to take that long for you.

So, I put together a FREE 40-minute webinar (a masterclass) that provides a roadmap for what worked for me.

Join My FREE 40-Minute R Webinar
(The Roadmap to a 6-Figure Data Scientist Career)

Literally 5-years of learning, consolidated into 40-minutes. It’s jammed packed with value. I wish I saw this when I was starting… It would have made a huge difference.

Step 2: Take Control Of Your Career

For my action-takers, if you are ready to become a Business Scientist, then read on.

If you need take your skills to the next level and DON’T want to wait 5-years to learn data science for business, AND you want a career you love that earns you $100,000+ salary (plus bonuses), AND you’d like someone to help guide you how to do this in UNDER 6-MONTHS or less….

Then I can help with that too.

I have a program that has helped over 3,000 students become data scientists in business with the R programming language. Don’t believe me? Read these testimonials.

My students have gotten:

All by learning data science for business with R. Get ready. The ride is wild. And the destination is AMAZING!

Join My 5-Course R-Track Program
(Become A 6-Figure Data Scientist)

P.S. Many of my students are getting their work to pay for education and skill advancement because it benefits your company. **Find out how to get your company to reimburse you for my courses. **

To leave a comment for the author, please follow the link and comment on their blog: business-science.io.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.