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

case_when..html

Case when


Description

This function allows you to use multiple if/else statements in one call.

It is called like dplyr::case_when(), but utilizes data.table::fifelse() in the background for improved performance.

Usage

case_when.(...)

Arguments

...

A sequence of two-sided formulas. The left hand side gives the conditions, the right hand side gives the values.

Examples

test_df <- tidytable(x = 1:10)

test_df %>%
  mutate.(case_x = case_when.(x < 5 ~ 1,
                              x < 7 ~ 2,
                              TRUE ~ 3))

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.