Skip to content
Back to skills

Rcpp

ASecurity

R Rcpp package for C++ integration. Use for writing high-performance C++ code callable from R.

  • 5 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 8, 2026
datagoc++performance

Security analysis

A100/100

Scanned September 8, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill Rcpp --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rcpp?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rcpp
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-rcpp-r-analytics-skill/badge)](https://www.skillsdirectory.com/skills/leolin990405-rcpp-r-analytics-skill)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: Rcpp
description: R Rcpp package for C++ integration. Use for writing high-performance C++ code callable from R.
---

# Rcpp Package

Seamless R and C++ integration.

## Inline C++

```r
library(Rcpp)

cppFunction('
  double sumC(NumericVector x) {
    int n = x.size();
    double total = 0;
    for(int i = 0; i < n; ++i) {
      total += x[i];
    }
    return total;
  }
')

sumC(1:1000000)
```

## Source File

```cpp
// mycode.cpp
#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
double meanC(NumericVector x) {
  int n = x.size();
  double total = 0;
  for(int i = 0; i < n; ++i) {
    total += x[i];
  }
  return total / n;
}
```

```r
sourceCpp("mycode.cpp")
meanC(1:100)
```

## Data Types

```cpp
// Vectors
NumericVector x;
IntegerVector y;
CharacterVector z;
LogicalVector b;

// Matrices
NumericMatrix m;

// Lists
List L;

// Data frames
DataFrame df;
```

## Vector Operations

```cpp
// [[Rcpp::export]]
NumericVector squareC(NumericVector x) {
  int n = x.size();
  NumericVector out(n);
  for(int i = 0; i < n; ++i) {
    out[i] = x[i] * x[i];
  }
  return out;
}

// Sugar (vectorized)
// [[Rcpp::export]]
NumericVector squareSugar(NumericVector x) {
  return x * x;
}
```

## Return List

```cpp
// [[Rcpp::export]]
List statsC(NumericVector x) {
  return List::create(
    Named("mean") = mean(x),
    Named("sd") = sd(x),
    Named("min") = min(x),
    Named("max") = max(x)
  );
}
```

## STL Algorithms

```cpp
#include <algorithm>

// [[Rcpp::export]]
NumericVector sortC(NumericVector x) {
  NumericVector y = clone(x);
  std::sort(y.begin(), y.end());
  return y;
}
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…