8 Awesome R Packages for Data Science You Should Be Using in 2026
As a data scientist, you likely already use popular R packages like dplyr, ggplot2, and caret on a daily basis. But the R ecosystem is vast, and there are many lesser-known yet incredibly useful packages that can supercharge your data science workflows. In this post, I‘ll introduce you to 8 powerful R packages for data visualization, data manipulation, machine learning, and more. Get ready to up your R game!
Packages for Data Visualization
Good data visualizations are key to exploring your data, conveying insights, and communicating results to stakeholders. While ggplot2 is the go-to tool for most R users, there are some next-level packages you should check out:
1. esquisse
Ever wished you could interactively build ggplot2 plots with a drag-and-drop interface? Enter esquisse – an RStudio add-in that lets you do just that! With esquisse, you can quickly explore different chart types, map variables to plot aesthetics, and tweak visual properties without writing any code. When you‘re done, esquisse provides the full ggplot2 code to reproduce the plot.
Here‘s how to get started with esquisse:
# Install esquisse from CRAN
install.packages("esquisse")
# Load esquisse
library(esquisse)
# Launch the interactive environment
esquisser()
esquisse is a great tool for rapid prototyping and for those new to ggplot2 syntax. Even as a more advanced user, I find myself using it frequently to iterate on visualizations.
2. gganimate
Static plots are so 2015. With gganimate, you can easily add animations to your ggplots to visualize time series, show changes over time, or even create animated art! The package provides a simple syntax to define how data should be transitioned between states.
For example, here‘s how you can create a bar chart race of top 10 baby names over time:
library(gganimate)
library(babynames) # example dataset
top10 <- babynames %>%
filter(prop >= 0.01) %>%
group_by(year, sex) %>%
top_n(10, prop)
animated_bars <- ggplot(top10, aes(x = prop,
y = fct_reorder(name, prop),
fill = sex)) +
geom_col() +
coord_flip(clip = "off") +
scale_x_continuous(expand = c(0, 0)) +
labs(x = "Proportion", y = "") +
transition_time(year) +
ease_aes(‘quadratic-in-out‘)
animate(animated_bars, fps = 25, duration = 20)
The possibilities with gganimate are endless – this just scratches the surface. Animations are a great way to engage your audience and convey insights from temporal data.
3. plotly
For interactive, web-based visualizations, look no further than plotly. This package lets you create dynamic charts with hover effects, drill-downs, and zooming – no JavaScript required! Plotly integrates seamlessly with ggplot2, so you can interact with your existing charts.
Making a ggplot interactive is as simple as:
library(plotly)
p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point()
ggplotly(p)
I use plotly whenever I need to create an interactive dashboard or let users explore multidimensional data. The ability to hover points for details, pan/zoom into areas of interest, and toggle traces on and off provides a richer experience than static plots.
Packages for Data Manipulation
Wrangling data into the right shape is a prerequisite for any analysis or modeling. Thanks to dplyr and the broader tidyverse, R offers a fantastic ecosystem for data manipulation. But there are a few packages that can further streamline your data wrangling pipelines:
4. tidyfast and collapse
For super efficient data manipulation on large datasets, check out tidyfast and collapse. Both packages re-implement dplyr and tidyr verbs in C++, delivering significant speedups.
Tidyfast aims to be a mostly drop-in replacement for dplyr/tidyr, so you can use the same APIs:
library(tidyfast)
df %>%
group_by(grp) %>%
summarise_at(vars(a, b), list(mean = mean, sd = sd))
Collapse, on the other hand, provides its own set of ultra-fast functions for grouping, summarizing, joining, and reshaping:
library(collapse)
collap(df, ~ grp, fmean = "a, b", fsd = "a, b")
In my experience, tidyfast and collapse really shine for repeated operations on large data (1 million+ rows). I‘ve seen 10-100x speedups compared to base dplyr in some cases. For most small-to-medium datasets though, the performance difference is negligible, so I tend to stick with dplyr for its familiarity and expressiveness.
5. tidylog
Debugging a long sequence of dplyr operations can be a pain. That‘s where tidylog comes in – it automatically prints out a log of dplyr operations, helping you see exactly what each step is doing to the data.
After installing tidylog, just load it after dplyr:
library(dplyr)
library(tidylog, warn.conflicts = FALSE)
iris %>%
group_by(Species) %>%
summarize_all(mean)
This will print out a log like:
select: dropped 0 variables
group_by: 1 grouping variable (Species)
summarize_all:
new variables:
* Sepal.Length = mean(Sepal.Length)
* Sepal.Width = mean(Sepal.Width)
* Petal.Length = mean(Petal.Length)
* Petal.Width = mean(Petal.Width)
Tidylog is a huge time-saver when writing and debugging complex dplyr pipelines. I highly recommend adding it to your workflow!
Packages for Machine Learning
R has excellent support for machine learning through libraries like caret. But in the era of tidy data principles and "model-driven engineering", some new packages are emerging to provide higher-level, pipeable APIs:
6. tidymodels
If you‘re a tidyverse fan, tidymodels is a natural fit for modeling workflows. It provides a unified, opinionated framework for modeling and machine learning using tidy principles. The core tidymodels packages let you fluidly move between data preprocessing, model fitting, performance evaluation, and interpretation.
Here‘s an example of a simple tidymodels workflow:
library(tidymodels)
lm_spec <- linear_reg() %>%
set_engine("lm")
lm_fit <- lm_spec %>%
fit(mpg ~ ., data = mtcars)
tidy(lm_fit)
glance(lm_fit)
augment(lm_fit)
The beauty of tidymodels is that it abstracts the underlying modeling packages, so you can use the same API whether you‘re fitting a linear regression, random forest, or deep learning model. There‘s also a strong emphasis on functional programming concepts like resampling, tuning, and composition.
If you‘re just getting started with machine learning in R, I highly recommend learning tidymodels first. It provides a solid foundation and abstracts away a lot of the low-level details.
7. probably
For a Bayesian approach to modeling, check out the probably package. It provides a probabilistic programming language embedded in R, letting you intuitively specify Bayesian models and perform inference.
A simple Bayesian linear regression in probably looks like:
library(probably)
model <- specify_model(
height ~ normal(mu, sigma),
mu <- a + b * weight,
a ~ normal(178, 20),
b ~ normal(0, 10),
sigma ~ uniform(0, 50)
)
set.seed(123)
samples <- fit_model(model, data = d, num_samples = 1000)
summarize_model(samples)
plot_model(samples)
Probably makes it easy to incorporate prior knowledge into models and quantify uncertainty in parameters and predictions. The API is elegant and focused on readability. If you‘re doing any sort of Bayesian analysis, probably is worth checking out.
8. superheat
Exploratory data analysis (EDA) is a key part of the modeling process, and heatmaps are a great tool for visualizing patterns and relationships in high-dimensional data. The superheat package provides a flexible, customizable take on heatmaps.
Here‘s a quick example of using superheat to visualize the correlations between variables in the mtcars dataset:
library(superheat)
mtcars %>%
select_if(is.numeric) %>%
cor() %>%
superheat(pretty.order.rows = T, pretty.order.cols = T)
In addition to correlation heatmaps, you can use superheat to visualize missing data patterns, cluster matrix rows/columns, and more. The plots are also highly customizable and work well with ggplot2 themes and scales.
Utility Packages
To wrap up, here are a few handy utility packages that don‘t quite fit into the above categories:
- r2d3: Create interactive D3 visualizations in R using familiar ggplot2 and tidyverse idioms
- cronR: Schedule R scripts and Rmarkdown reports to run at regular intervals
- shinyMobile: Build Shiny apps with mobile-first UI components, specially designed for small screens
Go Forth and Explore!
And there you have it – 8 powerful R packages to add to your toolkit in 2024. Of course, this is just a small sampling of the many excellent packages out there. I encourage you to explore and find the ones that fit your workflows best.
Do you have experience with any of these packages? Are there any other hidden gem packages you‘d add to the list? Let me know in the comments below!
Happy coding in R!