zifelse: Nested 'ifelse' statements with less typing

View source: R/ifelse-esque.R

zifelseR Documentation

Nested ifelse statements with less typing

Description

USE dplyr's case_when FOR ACTUAL WORKING CODE! This function is just code for my (Zach Burchill's) personal reference in the future. I anticipate that the framework that I wrote here for might be useful for me in the future.

Usage

zifelse(...)

Arguments

...

Paired unnamed arguments, where the first in each pair is an expression that evaluates to a logical vector, and the second is the replacement value. The last argument needs to be a single, unpaired default replacement value.

Value

A vector of the same length as the logical vector that is the first argument

Examples


a <- runif(1000)
zifelse(a >= 0   & a <= 0.33, 1,
        a > 0.33 & a <= 0.66, 2,
        3)

burchill/zplyr documentation built on Feb. 2, 2023, 11:01 a.m.