lundi 26 novembre 2018

if statement in a funcion with dplyr verbs

Is it possible to write something like this:

g <- function(method){
dataset %>%
if (method==1){
mutate(boot1 =some_formula1)
} else {  
mutate(boot2 =some_formula2)
 }
}

a<- g(1)

Or is the only choice to use ifelse or case_when inside mutate?

Aucun commentaire:

Enregistrer un commentaire