Easier ggplot with the ggeasy R package

The ggplot2 data visualization R package is extremely powerful and flexible. However, it’s not always easy to remember how to do every task – especially if you’re not a frequent user. How do you change the size of a graph title? How do you remove legend titles? My usual solution is to save RStudio code snippets for things I have trouble remembering. But there’s also a package that can help: ggeasy.

As the name says, the goal of ggeasy is to, well, make ggplot2 easy – or at least easier. It has what some people may find to be more intuitive functions for typical tasks, mostly around text and axis formatting. (This package doesn’t affect the way lines, points, and bars look and behave). All ggeasy functions start with easy_ so it’s, yes, easy to find them using RStudio autocomplete. You can see how that works in the video above.

If you’d like to follow along with my example below, ggeasy is on CRAN, so you can install it with install.packages("ggeasy"). I will also be using the ggplot2 (naturally), dplyr, rio, and lubridate packages. Later, I will add the patchwork package for super simple placement of multiple graphs; that’s also on CRAN.

For this example, I’m going to use data about what’s on most people’s minds these days: coronavirus. You can download a CSV file with data by U.S. state from the Coronavirus Tracking Project with

destfile = "covid19.csv")

(You can name the destfile destination file anything you’d like.) I used rio::import() to import the data, but you can also use readr::read_csv(), read.csv(), data.table::fread(), or any other function to import the CSV.

Copyright © 2020 IDG Communications, Inc.

Source link