rtern

R-CMD-check Codecov test coverage

Overview

rtern brings a conditional ternary operator using ? and : to R.

This groundbreaking spoonful of syntactic sugar will supercharge your workflow and see you bubble to the top of Kaggle leaderboards.

Yes, we know that it is possible to perform conditional assignment in base R multiple ways:

x <- if(y > 1) 1 else 2
# vectorized form:
x <- ifelse(y > 1, 1, 2)

However we’re sure you’ll agree that once you can do the same using only…

x <- y > 1 ? 1 : 2

…your models will converge faster, ROC AUC will approach 1 and Hadley Wickham will be starring your repos.

The only downsides are that your linter won’t like it and that this masks the base functionality of ? in R .
As of v0.1 help files can still be accessed by the ? operator whilst rtern is attached!

Who needs help files? Not you, champ.

Why?

rtern is a lighthearted project for practicing package development and nonstandard evaluation in R. The ? operator implementation borrows heavily from this Stack Exchange answer.

Installation

You can can’t install a released version of rtern from CRAN with:

install.packages("rtern")

…sorry

Instead you can install from GitHub with:

# install.packages("devtools")
devtools::install_github("grddavies/rtern")