A new R package for Business Analytics... radiant

Written by Matt Dancho



I’m super impressed by the radiant R package. With no prior experience with radiant, I was able to complete a short business analytics report in under 10-minutes.

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

Video Tutorial

See how in 10-minutes I made a quick business analytics report with radiant.

What you make in this R-Tip

By the end of this tutorial, you’ll use Radiant to create a reproducible Business Analytics Report and save it as HTML.

Reproducible Business Analytics Report (made with radiant)

Thank You Developers

Before we go any further, I want to say thanks to the open source developers of Radiant. The programmer that graciously developed radiant and has given it to us free of charge is Vincent Nijs.

Radiant Setup

Follow these instructions to set up the radiant package and tutorial.

  • Install Radiant
  • Load the libraries and data
  • Run radiant() (there’s also an Add-In if you use Rstudio)

Radiant’s Shiny UI

This opens up the Radiant Shiny User Interface, a Shiny App that runs locally in a new Google Chrome Window.

Step 1 - Working with Data

Next, lets load our data. I added data into the Rstudio Global Environment previously when I ran data(walmart_sales_weekly).

One of the options is to load data from the Global Environment, so let’s do this.

Step 2 - Visualize

We can make a quick plot to investigate the sales data over time by Sales ID (store - department identifier). This highlights the differing sales trends by Store-Department.

  1. Head over the Visualize Section within the Data Tab
  2. Select Line Plot, and Y-Axis will be Weekly Sales, X-Axis is Date, and Facet Row is ID
  3. Click Create Plot to make the visualization

Step 3 - Starting the Report

At this point we can begin building our report.

  1. On the Visualize Section, scroll down and click the little report icon
  2. This send you to the Report Tab where you can Knit report

Bada-Bing… Bada Boom! We have the beginnings of a Business Analytics Report.

Step 4 - Modeling (Creating a Price Model)

The next step in our workflow is to model the weekly sales data. My goal is to create a Pricing Model that looks for dependencies between the weekly sales volume by department and factors like markups, fuel price, temperature (weather), etc. We can easily do this in radiant.

Head over to the Model Tab and select Linear Regression (OLS).

  1. First select Weekly Sales as the response variable and select the explanatory variables shown.
  2. Then click Estimate Model to make a linear regression model
  3. Review the OLS Linear regression summary results. This is our very basic pricing model.

Bonus - Residual & Coefficient Plots

As a bonus for making it this far, I’m showing you how you can quickly make some awesome visuals for your Business Analytics Report.

Residuals Plot

This plot helps us see how well the model is performing. It’s worth mentioning that we are seeing a lot of clusters, which means a non-linear model may be a better model.

Coefficient Plot

This plot helps us see the effect of a 1-unit change to the modeled price. It appears that the model is very sensitive to Fuel Price. Keep in mind that the units are important for comparison.

  • A change in $1 of fuel price is a lot.
  • A change in 1-degree Fahrenheit for Temperature is not that much.

Step 5 - Finish the Report

Once we are happy, we can finish our report. Just hit the “Report Button” to send the results from the Modeling Tab to the Report Tab.

On the reporting tab:

  1. Add a title and sections to your report
  2. Move the code chunks to follow the order
  3. Hit Save Report (I saved as HTML in the Youtube Video)

The report is saved as an HTML document (assuming you switched from Notebook to HTML like I did in the video.)

Recap

You just created a report using radiant. But there’s a lot more to data science.

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.

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 action

For my action-takers, if you are ready to 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 you do this in UNDER 6-MONTHS or less….

Then I can help with that too. There’s a link in the FREE 40-minute webinar for a special price (because you are special!) and taking that action will kickstart your journey with me in your corner.

Get ready. The ride is while. And the destination is AMAZING!


👇 Top R-Tips Tutorials you might like:

  1. mmtable2: ggplot2 for tables
  2. ggdist: Make a Raincloud Plot to Visualize Distribution in ggplot2
  3. ggside: Plot linear regression with marginal distributions
  4. DataEditR: Interactive Data Editing in R
  5. openxlsx: How to Automate Excel in R
  6. officer: How to Automate PowerPoint in R
  7. DataExplorer: Fast EDA in R
  8. esquisse: Interactive ggplot2 builder
  9. gghalves: Half-plots with ggplot2
  10. rmarkdown: How to Automate PDF Reporting
  11. patchwork: How to combine multiple ggplots
  12. Geospatial Map Visualizations in R

Want these tips every week? Join R-Tips Weekly.