Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ifelse..html

Fast ifelse


Description

ifelse.() utilizes data.table::fifelse() in the background, but automatically converts NAs to their proper type.

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.()
test_df <- data.table(x = x)

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

tidytable

Tidy Interface to 'data.table'

v0.6.1
MIT + file LICENSE
Authors
Mark Fairbanks [aut, cre], Abdessabour Moutik [ctb], Matt Carlson [ctb], Ivan Leung [ctb], Ross Kennedy [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.