Back to Browse

if_else R Function of dplyr Package (2 Examples) | Create Variable Based On Input Vector in RStudio

3.7K views
Dec 11, 2019
6:19

How to apply the if_else function of the dplyr package in the R programming language. More details: https://statisticsglobe.com/r-if_else-function-dplyr-package R code of this tutorial: install.packages("dplyr") # Install dplyr library("dplyr") # Load dplyr x <- -3:3 # Example vector x if_else(x < 0, "neg", "pos") # Basic application of if_else x_NA <- c(-3:3, NA) # Example vector with NA x_NA if_else(x_NA < 0, "neg", "pos", "xxx") # Apply if_else with NA condition

Download

0 formats

No download links available.

if_else R Function of dplyr Package (2 Examples) | Create Variable Based On Input Vector in RStudio | NatokHD