Written by Matt Dancho

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

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)

# 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!

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.

• Itâ€™s called RFM Analysis (or Recency-Frequency-Monetary Analysis), when we group customers by spending habits such as how many days since last transaction, how many times they have transacted, and the total amount the customer has spent.
• A big mistake many business analysts (and data scientists) make is not including customer features like Age and for a weight-loss company how much the customer weighs. This helps us further create Customer Segments.
• If done properly, we can develop Customer Avatars, that describe the unique groups within our data (i.e. the unique customer segments). Then we can develop marketing that speaks to those Customer Avatars. And by targeting them, we can increase sales.

## 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).

# 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:

• Machine Learning
• Time Series
• Financial Analysis
• Geospatial Analysis
• Text Analysis and NLP
• Shiny Web App Development

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.

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.

• Vehicle Class is the group in our data set
• The summary metric is going to be the median displacement, highway fuel economy, city fuel economy, and number of cylinders
• Weâ€™ll need to rescale each of the numeric variable to be between 0 and 1 (so they appear correctly on the radar chart)

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.

• A simple radar plot is only 1 line of code.
• And a custom faceted radar plot isnâ€™t bad either once you know ggplot2

Pro-Tip: Use my R Cheat Sheet for customized plotting.

Making a radar plot is as simple as 1 line of 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.

â€¦which produces this data visualization.

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

• SUV and Pickup are similar
• Compact, Subcompact, and Midsize are similar
• 2-Seater and Minivans are outliers

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

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.

â€¦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:

• Compact, Subcompact, and Midsize are similar
• Pickup and SUV are similar
• 2 Seater is Different, and so is Minivan

# 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.

# Struggling to become a data scientist?

You know the feeling. Being unhappy with your current job.

Promotions arenâ€™t happening. Youâ€™re stuck. Feeling Hopeless. Confusedâ€¦

And youâ€™re praying that the next job interview will go better than the last 12â€¦

â€¦ But you know it wonâ€™t. Not unless you take control of your career.

The good news isâ€¦

Iâ€™ve helped 6,107+ students learn data science for business from an elite business consultantâ€™s perspective.

Iâ€™ve worked with Fortune 500 companies like S&P Global, Apple, MRM McCann, and more.

And I built a training program that gets my students life-changing data science careers (donâ€™t believe me? see my testimonials here):

# Whenever you are ready, hereâ€™s the system they are taking:

Hereâ€™s the system that has gotten aspiring data scientists, career transitioners, and life long learners data science jobs and promotionsâ€¦

P.S. - Samantha landed her NEW Data Science R Developer job at CVS Health (Fortune 500). This could be you.