Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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. ?
grafify Video Tutorial
For those that prefer Full YouTube Video Tutorials.
Learn how to use grafify
in our free 7-minute YouTube video.
Watch our full YouTube Tutorial
What is grafify?
grafify
is a new R package for making great-looking ggplot2
graphs quickly in R. It has 19 plotting functions that simplify common ggplot graphs and provide color-blind friendly themes.
We’ll go through a short tutorial to get you up and running with grafify
.
Before we get started, get the R Cheat Sheet
grafify
is great for making quick ggplot2
plots. But, you’ll still need to learn how to wrangle data with dplyr
and visualize data with ggplot2
. For those topics, I’ll use the Ultimate R Cheat Sheet to refer to dplyr
and ggplot2
code in my workflow.
Quick Example:
Download the Ultimate R Cheat Sheet. Then Click the “CS” next to “ggplot2” opens the Data Visualization with ggplot2 Cheat Sheet.
Now you’re ready to quickly reference ggplot2
functions.
Onto the tutorial.
How grafify works
The grafify
package extends ggplot2
by adding several simplified plotting functions. In this tutorial, we’ll cover:
-
2-Variable Functions:
plot_scatterbar_sd()
,plot_scatterbox()
, andplot_dotviolin()
-
3-Variable Functions:
plot_3d_scatterbox()
-
Before-After Functions:
plot_befafter_colors()
Load the Libraries and Data
First, run this code to:
- Load Libraries: Load
grafify
andtidyverse
. - Import Data: We’re using the
mpg
dataset that comes withggplot2
.
Scatterbar SD Plot
First, we can make a Scatterbar Plot that shows the data points along with error bars at a standard deviation. Simply use plot_scatterbar_sd()
.
Scatterbox Plot
Next, we can make a Scatterbox Plot that shows a custom boxplot / jitter plot combination. I’ve added a jitter point to show the distribution. Simply use plot_scatterbox()
.
Dotviolin Plot
Next, we can make a Dotviolin Plot that shows a custom violin plot / dotplot combination. Simply use plot_dotviolin()
.
Scatterbox 3D Plot
Next, we can make a 3D Scatterbox Plot that shows three variables using boxplot / jitter plot combination. This is great for drilling into multiple categories. Simply use plot_3d_scatterbox()
.
Before-After Plot
Finally, we can make a Before-After Plot that shows changes between two states (in this case how various models changed in MPG Fuel Efficiency from 1999 to 2008). This is great for comparing two states. Simply use plot_befafter_colors()
.
Summary
With 19 plotting functions, the grafify
package makes it quick and easy to make custom ggplot2
visualizations that are easy to visualize and explore data. With that said, it’s critical to learn ggplot2
for plots beyond what grafify
offers.
If you’d like to learn ggplot2
and data science for business, then read on. ?
My Struggles with Learning Data Science
It took me a long time to learn data science. 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 smartly
-
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 called the 5-Course R-Track System. It’s an integrated system containing 5 courses that work together on a learning path. Through 5+ 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 2000+ data scientists that are ready to help you succeed.
Ready to take the next step? Then let’s get started.
? Top R-Tips Tutorials you might like:
- mmtable2: ggplot2 for tables
- ggside: Plot linear regression with marginal distributions
- DataEditR: Interactive Data Editing in R
- openxlsx: How to Automate Excel in R
- officer: How to Automate PowerPoint in R
- DataExplorer: Fast EDA in R
- esquisse: Interactive ggplot2 builder
- gghalves: Half-plots with ggplot2
- rmarkdown: How to Automate PDF Reporting
- patchwork: How to combine multiple ggplots
Want these tips every week? Join R-Tips Weekly.
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.