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.
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. 👇
See how in 10-minutes I made a quick business analytics report with
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
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.
Follow these instructions to set up the
radiant package and tutorial.
- Install Radiant
- Load the libraries and data
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
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.
- Head over the Visualize Section within the Data Tab
- Select Line Plot, and Y-Axis will be Weekly Sales, X-Axis is Date, and Facet Row is ID
- Click Create Plot to make the visualization
Step 3 - Starting the Report
At this point we can begin building our report.
- On the Visualize Section, scroll down and click the little report icon
- 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
Head over to the Model Tab and select Linear Regression (OLS).
- First select Weekly Sales as the response variable and select the explanatory variables shown.
- Then click Estimate Model to make a linear regression model
- 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.
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.
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:
- Add a title and sections to your report
- Move the code chunks to follow the order
- 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.)
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.
My Struggles with Learning Data Science
It took me a long time to learn how to apply data science to business. And I made a lot of mistakes as I fumbled through learning R.
I specifically had a tough time navigating the ever-increasing landscape of tools and packages, trying to pick between R and Python, and getting lost along the way.
If you feel like this, you’re not alone.
In fact, that’s the driving reason that I created Business Science and Business Science University (You can read about my personal journey here).
What I found out is that:
- Data Science does not have to be difficult, it just has to be taught from a business perspective
- Anyone can learn data science fast provided they are motivated.
How I can help
If you are interested in learning R and the ecosystem of tools at a deeper level, then I have a streamlined program that will get you past your struggles and improve your career in the process.
It’s my 5-Course R-Track System. It’s an integrated system containing 5 courses that work together on a learning path. Through 8 projects, you learn everything you need to help your organization: from data science foundations, to advanced machine learning, to web applications and deployment.
The result is that you break through previous struggles, learning from my experience & our community of 2653 data scientists that are ready to help you succeed.
Ready to take the next step? Then let’s get started.