I am trying to sum up all the numeric variables in iris, and not sum the non-numeric variables.
However, this does not work:
iris %>% map_dbl(function(x) if(is.numeric(x)) sum(x))
Why doesn't this work? It works if I remove the non-numeric variables first, as below
iris[1:4] %>% map_dbl(function(x) if(is.numeric(x)) sum(x))
Could we still use map_dbl for this case?