rguides

R Machine Learning Packages in 2026: The Complete Landscape

The R machine learning ecosystem has matured significantly. In 2026, data scientists have access to a rich set of packages covering everything from traditional statistics to cutting-edge deep learning. This guide surveys the most important machine learning packages in R and when to use each one.

The modern R ML stack

The R machine learning landscape has consolidated around several key frameworks:

  • tidymodels, The modern, tidyverse-aligned framework for modeling
  • caret, Still widely used for classical methods
  • h2o, Enterprise-grade AutoML
  • torch, Deep learning (R interface to PyTorch)
  • xgboost and lightgbm, Gradient boosting implementations
  • rstan and brms, Bayesian machine learning

Tidymodels: the new standard

The tidymodels framework has become the go-to choice for most machine learning tasks in R. It provides a unified interface that feels like the tidyverse:

library(tidymodels)

# Define a model
lm_model <- linear_reg() %>%
  set_engine("lm")

# Fit the model
lm_fit <- lm_model %>%
  fit(mpg ~ wt + hp, data = mtcars)

The key packages in the tidymodels ecosystem include:

  • parsnip, Unified interface for model definitions
  • recipes, Data preprocessing
  • workflows, Pipelining
  • tune, Hyperparameter optimization
  • yardstick, Model evaluation

Each of these packages handles a distinct phase of the modeling pipeline, from defining the model formula with parsnip to preprocessing data with recipes and evaluating predictions with yardstick. The example below assembles them into a complete classification workflow using a random forest on the iris dataset, showing how the pieces connect in practice.

Classification example

library(tidymodels)
library(tidyverse)

# Load data
data("iris")

# Split data
iris_split <- iris %>%
  initial_split(prop = 0.8, strata = Species)

iris_train <- training(iris_split)
iris_test <- testing(iris_split)

# Define model
rf_spec <- rand_forest(trees = 100) %>%
  set_mode("classification")

# Fit
rf_fit <- rf_spec %>%
  fit(Species ~ ., data = iris_train)

# Predict
predictions <- rf_fit %>%
  predict(iris_test) %>%
  bind_cols(iris_test)

# Evaluate
predictions %>%
  accuracy(truth = Species, estimate = .pred_class)

This basic classification workflow covers the core pattern: split, define a model spec, fit, predict, and evaluate. For datasets where a single random forest does not squeeze out enough accuracy, gradient boosting methods often provide the next step up in predictive performance without requiring a fundamentally different workflow.

Gradient boosting: xgboost and lightgbm

For tabular data, gradient boosting methods consistently deliver top performance. The xgboost and lightgbm packages provide fast implementations:

library(xgboost)

# Prepare data
dtrain <- xgb.DMatrix(data = as.matrix(train[, -1]), label = train$y)
dtest <- xgb.DMatrix(data = as.matrix(test[, -1]), label = test$y)

# Train
params <- list(
  objective = "binary:logistic",
  eval_metric = "auc",
  max_depth = 6,
  learning_rate = 0.1
)

model <- xgb.train(
  params = params,
  data = dtrain,
  nrounds = 100,
  watchlist = list(train = dtrain, test = dtest)
)

XGBoost uses the xgb.DMatrix data structure and a parameter list to control tree depth, learning rate, and evaluation metric. This pattern works well but comes with a learning curve around the native API conventions.

lightgbm offers similar functionality with often faster training times:

library(lightgbm)

train_data <- lgb.Dataset(
  data = as.matrix(train_features),
  label = train_labels
)

params <- list(
  objective = "binary",
  metric = "auc",
  learning_rate = 0.1,
  num_leaves = 31
)

model <- lgb.train(
  params = params,
  data = train_data,
  num_iterations = 100
)

Gradient boosting methods like xgboost and lightgbm dominate tabular data competitions, but they cannot handle image, audio, or sequence data directly. When your problem involves unstructured inputs, neural networks become the tool of choice, and the torch package gives R users access to the same PyTorch backend that powers production deep learning in Python.

Deep learning with torch

For neural networks, the torch package provides native PyTorch functionality in R:

library(torch)

# Define a simple neural network
net <- nn_module(
  initialize = function(...) {
    self$fc1 <- nn_linear(784, 256)
    self$fc2 <- nn_linear(256, 10)
    self$dropout <- nn_dropout(0.2)
  },
  forward = function(x) {
    x %>%
      torch_flatten(start_dim = 2) %>%
      self$fc1() %>%
      nn_relu() %>%
      self$dropout() %>%
      self$fc2()
  }
)

# Train
model <- net()
optimizer <- optim_adam(model$parameters, lr = 0.01)

for (epoch in 1:10) {
  model$train()
  optimizer$zero_grad()
  
  batch <- dataset_mnist_batch(batch_size = 32)
  output <- model(batch$data)
  loss <- nnf_cross_entropy(output, batch$target)
  
  loss$backward()
  optimizer$step()
}

Training a neural network from scratch gives you full control over architecture and training dynamics, but it requires significant effort to tune correctly. When you need a competitive baseline quickly, or when you are not sure which algorithm will perform best on your dataset, automated machine learning tools can accelerate the model selection process considerably.

H2O autoML

For quick prototyping and automated model selection, H2O provides powerful AutoML capabilities:

library(h2o)
h2o.init()

# Prepare data
train_h2o <- as.h2o(train_data)
test_h2o <- as.h2o(test_data)

# Run AutoML
aml <- h2o.automl(
  x = features,
  y = target,
  training_frame = train_h2o,
  max_runtime_secs = 300,
  leaderboard_frame = test_h2o
)

# Get leaderboard
aml@leaderboard

AutoML tools like H2O produce point predictions and leaderboards, but they do not quantify uncertainty in model parameters or predictions. When your application requires credible intervals rather than just a single number, or when you have strong prior domain knowledge to incorporate, Bayesian methods fill that gap naturally.

Bayesian methods: rstan and brms

For Bayesian inference, rstan provides the R interface to Stan:

library(rstan)
library(brms)

# Fit a Bayesian regression
fit <- brm(
  mpg ~ wt + hp + cyl,
  data = mtcars,
  family = gaussian(),
  prior = prior(normal(0, 10), class = b),
  iter = 2000,
  chains = 4
)

summary(fit)

Choosing the right package

Here’s a quick decision guide:

  • General ML, tidymodels
  • Tabular data, maximum accuracy, xgboost, lightgbm
  • Deep learning, torch
  • AutoML quick prototype, h2o
  • Bayesian inference, brms
  • Time series, forecast, fable
  • Model interpretability, DALEX, iml

Performance comparison

For the classic Titanic classification problem, here’s a rough performance guide:

  • Logistic Regression, 78-80%
  • Random Forest, 80-83%
  • XGBoost, 83-86%
  • LightGBM, 83-86%
  • H2O AutoML, 84-87%
  • Neural Network (torch), 80-85%

Your results will vary based on feature engineering and cross-validation strategy.

Installation tips

Most ML packages are available from CRAN:

install.packages(c(
  "tidymodels",
  "xgboost",
  "lightgbm",
  "h2o",
  "brms",
  "torch"
))

The CRAN install above covers most packages, but torch needs an additional step: it ships the R package from CRAN while the actual PyTorch C++ library must be installed separately through the package’s helper function. On macOS with Apple Silicon, torch::install_torch() downloads a prebuilt binary that includes Metal acceleration, so GPU training works without extra configuration.

For torch on macOS with Apple Silicon:

torch::install_torch()

The tidymodels core

The tidymodels framework is R’s unified machine learning API. parsnip standardizes model interfaces: linear_reg(), logistic_reg(), decision_tree(), rand_forest(), boost_tree(), and 50+ other model types are accessed with the same API regardless of the underlying engine. set_engine("glmnet") or set_engine("ranger") switches the backend without changing the model specification code.

recipes handles feature engineering in a reproducible, leakage-free way. Steps learned on training data (normalization scales, PCA components, imputation medians) are stored in the recipe and applied automatically to test and new data. This design prevents the common mistake of fitting preprocessing on the full dataset.

tune and finetune handle hyperparameter optimization. tune_grid() evaluates a grid of parameter combinations using resampling. tune_bayes() uses Bayesian optimization to find good parameters more efficiently than a full grid search. finetune::tune_race_anova() eliminates clearly poor configurations early, focusing computation on promising regions.

Gradient boosting and ensemble methods

xgboost and lightgbm are the most widely used gradient boosting implementations in R. Both are available as parsnip engines: boost_tree() |> set_engine("xgboost") or set_engine("lightgbm"). LightGBM is generally faster for datasets with many features; XGBoost has a more mature R interface with better documentation.

stacks provides stacking ensembles within the tidymodels framework: fit multiple models with tune_grid(), then combine their predictions with stacks::stack_add() and learn blending weights with stacks::blend_predictions(). The stacking workflow is fully compatible with the tidymodels resampling infrastructure.

AutoML options

h2o.automl() from the H2O package trains and evaluates multiple model types automatically, returning a leaderboard ranked by cross-validated performance. It requires a running H2O cluster (h2o.init()) but provides impressive out-of-the-box performance for tabular data. mlr3 with mlr3automl provides a more modular AutoML framework built on the mlr3 infrastructure.

For users who want quick baselines without hyperparameter tuning, tidymodels with auto_ml() from automl or DALEX::model_performance() to compare several models provides a lightweight path to competitive baselines.

Package selection guidance

For new ML projects in R, start with tidymodels for the unified interface and then add algorithm-specific packages as the recipe calls for them: xgboost for gradient boosting, ranger for random forests, kernlab for SVMs. Avoid building workflows around legacy packages like caret, tidymodels supersedes it with a better API. For deep learning, torch is the more actively maintained option compared to keras. Evaluate any package by checking its last CRAN release date and the volume of open issues on GitHub before adding it as a dependency.

Ecosystem overview

R’s ML ecosystem spans three tiers. The tidymodels framework provides a unified interface to 100+ model engines without learning separate APIs for each. Specialized packages (xgboost, ranger, lightgbm) implement specific algorithms with full parameter control. Infrastructure packages (vetiver, pins, plumber) handle model deployment and serving. These tiers work together: train with tidymodels, store with vetiver/pins, serve with plumber.

Performance at scale

For datasets too large for in-memory R, sparklyr connects to Apache Spark clusters. arrow with duckdb handles multi-gigabyte files efficiently without a cluster. For neural networks, torch and keras use GPUs. CPU-bound algorithms benefit from future::plan(multisession) for parallel model fitting, particularly for cross-validation where folds are independent.

Emerging packages

The R ML ecosystem continues to grow. mlr3 is a modern ML framework that competes with tidymodels, with a focus on extensibility and R6-based architecture. tabnet provides tabular deep learning (TabNet architecture). bonsai extends tidymodels with additional tree-based engines including lightgbm. shapviz provides SHAP value visualization for any model. probably adds calibration and threshold tools to tidymodels workflows. Monitor r-universe.dev for early access to packages before CRAN submission.

The R ML ecosystem in 2026

R’s machine learning ecosystem has matured significantly. tidymodels provides a unified interface that covers preprocessing, model fitting, cross-validation, and tuning for most common ML use cases. The underlying model packages, ranger, xgboost, glmnet, and others, are well-maintained and competitive in performance with their Python equivalents. For classical statistical learning, R remains the most comprehensive environment.

Deep learning is the area where R’s ecosystem is thinnest. Keras and torch provide neural network capabilities, but the community developing novel architectures and pre-trained models primarily targets Python. Using pre-trained transformer models from Hugging Face requires either reticulate or exporting model outputs from Python for use in R. For practitioners whose work requires state-of-the-art deep learning, Python is the natural primary language with R for analysis and visualization.

Package selection criteria

When multiple packages address the same problem, choosing between them requires considering maintenance status, documentation quality, tidymodels integration, and community adoption. A package that is actively maintained has a more recent commit, responds to issues, and adds support for new features. One that integrates with tidymodels can be used with the full tuning and evaluation infrastructure rather than requiring custom code for those steps.

Documentation matters for learning and for troubleshooting. A package with comprehensive vignettes that demonstrate realistic use cases is faster to learn than one with only function-level documentation. User community size matters for getting help: a package with an active Stack Overflow presence and CRAN community means your questions are more likely to have answers.

Stability and reproducibility

For production ML systems, package stability is a critical consideration. A package that breaks its API with every minor version requires constant maintenance of downstream code. CRAN packages have a stability requirement: breaking changes must be communicated and deprecated paths maintained for reasonable periods. GitHub-only packages have no such requirement.

renv lockfiles record the exact package versions used to train a model. Reproducing the same model months later requires the same package versions. Relying on CRAN packages and locking their versions in renv is the most reliable approach for long-lived ML systems. Packages that are only on GitHub or that require specific system libraries need additional infrastructure to reproduce reliably.

Conclusion

The R machine learning ecosystem in 2026 offers powerful tools for every use case. Start with tidymodels for most tasks, reach for gradient boosting (xgboost, lightgbm) when you need maximum performance on tabular data, and use torch for deep learning. H2O provides excellent AutoML for quick experiments, while brms makes Bayesian methods accessible.

The tidyverse-aligned packages have made machine learning in R more approachable than ever, with consistent syntax and excellent documentation.

See also