ifelse. | R Documentation |
Fast version of base::ifelse()
.
ifelse.(conditions, true, false, na = NA)
conditions |
Conditions to test on |
true |
Values to return if conditions evaluate to |
false |
Values to return if conditions evaluate to |
na |
Value to return if an element of test is |
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.