I have a very simple ifelse() statement. With the mtcars dataset, I want to define a parameter for the vs column. If the user says "all", then it should give all unique values (0 and 1, here). However, if they specify an actual value, it should give that value. Though the false condition works, the TRUE condition does not. Why not?
library(dplyr)
data("mtcars")
vs_parameter <- c("all")
ifelse(vs_parameter == "all", unique(mtcars$vs), vs_parameter)
#but if you change vs_parameter <- c(1), it does work