r-performance

Profile R code with profvis and benchmark optimizations with bench::mark.

1|Updated May 13, 2026
One-click install
npx skills add https://github.com/impact-initiatives/ana_app --skill r-performance-impact-initiatives
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: r-performance
Source: https://github.com/impact-initiatives/ana_app/tree/main/.claude/.claude/skills/r-performance
Command: npx skills add https://github.com/impact-initiatives/ana_app --skill r-performance-impact-initiatives

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

R performance tuning often fails because developers optimize blindly instead of identifying real bottlenecks and validating faster alternatives.

Core Features & Use Cases

  • Profiling-first workflow: Use profvis, Rprof(), and system.time() to locate where time is actually spent.
  • Benchmark-driven optimization: Use bench::mark() to compare approaches (including memory) before adopting changes.
  • Targeted optimization techniques: Choose appropriate strategies such as parallelization (in_parallel()), data backend selection (data.table vs dplyr vs base R), and vctrs-based type stability.
  • Use Case: When a large dataset pipeline is slow, profile on realistic data, benchmark candidate vectorized/parallel versions, then refactor hot paths using type-stable vctrs or faster backends as appropriate.

Quick Start

Run profiling with profvis on your slow R code to find the true bottlenecks, then benchmark alternative implementations with bench::mark() and apply the fastest safe changes.

Frequently Asked Questions about r-performance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find bottlenecks in slow R code?

Find bottlenecks in slow R code by using profvis or Rprof to profile runtime, which shows exactly where execution time is spent. This profiling-first approach identifies true hot paths before attempting any optimizations.

What is the best way to benchmark alternative R implementations?

The best way to benchmark alternative R implementations is using bench::mark to compare execution time and memory usage. This evidence-based approach validates that changes actually improve performance before adoption.

How does data.table compare to dplyr for R performance optimization?

data.table compared to dplyr offers different backend performance for joins and aggregations. Benchmarking both with bench::mark on realistic data reveals which backend provides better runtime and memory efficiency for your specific workload.

When do I need parallel processing in R?

You need parallel processing in R when profiling reveals parallelizable computations that dominate runtime. Use in_parallel() only after profiling confirms the overhead is justified by significant performance gains.

How do I use vctrs to speed up R functions?

Use vctrs to speed up R functions by enforcing type and size stability, which minimizes expensive memory reallocations during vectorized operations. This targeted optimization refactors hot paths for better runtime efficiency.

Does R performance profiling require large datasets?

R performance profiling requires realistic datasets that mimic production scale to accurately locate true bottlenecks. Profiling on small data misses memory allocation issues and hot paths that only emerge under heavy workloads.