ifelse.: Fast ifelse

View source: R/if_else.R

ifelse.R Documentation

Fast ifelse

Description

Fast version of base::ifelse().

Usage

ifelse.(conditions, true, false, na = NA)

Arguments

conditions

Conditions to test on

true

Values to return if conditions evaluate to TRUE

false

Values to return if conditions evaluate to FALSE

na

Value to return if an element of test is NA

Examples

x <- 1:5
ifelse(x < 3, 1, 0)

# Can also be used inside of mutate()
df <- data.table(x = x)

df %>%
  mutate(new_col = ifelse(x < 3, 1, 0))

tidytable documentation built on Oct. 5, 2023, 5:07 p.m.