Skip to content
Back to skills

Assertr

ASecurity

R assertr package for assertion pipelines. Use for assertive programming with data frames.

  • 5 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added June 4, 2026
datago

Security analysis

A100/100

Scanned June 4, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Assertr?

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

Security grade badge for Assertr
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-assertr/badge)](https://www.skillsdirectory.com/skills/leolin990405-assertr)

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: assertr
description: R assertr package for assertion pipelines. Use for assertive programming with data frames.
---

# assertr

Assertive programming for R analysis pipelines.

## Basic Assertions

```r
library(assertr)
library(dplyr)

df %>%
  assert(within_bounds(0, 120), age) %>%
  assert(not_na, name) %>%
  assert(is_uniq, id)
```

## Predicates

```r
# Built-in predicates
within_bounds(0, 100)    # Value in range
in_set(c("A", "B", "C")) # Value in set
not_na                   # Not NA
is_uniq                  # Unique values

# Custom predicate
is_positive <- function(x) x > 0

df %>%
  assert(is_positive, income)
```

## Verify

```r
# Row-level assertions
df %>%
  verify(age >= 0) %>%
  verify(income > 0) %>%
  verify(nrow(.) > 0)
```

## Insist

```r
# Statistical assertions
df %>%
  insist(within_n_sds(3), age) %>%
  insist(within_n_mads(3), income)
```

## Chain Assertions

```r
df %>%
  verify(nrow(.) > 0) %>%
  assert(not_na, id, name) %>%
  assert(within_bounds(0, 120), age) %>%
  insist(within_n_sds(3), income) %>%
  # Continue with analysis
  group_by(category) %>%
  summarize(mean_age = mean(age))
```

## Error Handling

```r
# Custom error function
df %>%
  chain_start %>%
  assert(not_na, name) %>%
  assert(is_uniq, id) %>%
  chain_end(error_fun = error_append)

# Just warn
df %>%
  assert(not_na, name, error_fun = just_warn)

# Return logical
df %>%
  assert(not_na, name, error_fun = error_logical)
```

## Assert Rows

```r
# Row-wise assertions
df %>%
  assert_rows(
    rowSums,
    within_bounds(0, 100),
    col1, col2, col3
  )

# Custom row function
df %>%
  assert_rows(
    function(x) x$end - x$start,
    function(x) x >= 0,
    end, start
  )
```

## Column Assertions

```r
# Check column existence
df %>%
  has_all_names("id", "name", "age")

# Check column types
df %>%
  assert(is.numeric, age, income) %>%
  assert(is.character, name)
```

## Success/Failure Functions

```r
# Custom success function
df %>%
  assert(not_na, name,
    success_fun = success_append,
    error_fun = error_append)
```

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…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.