why the code is not work, it is worked if I removed the non numeric variable first, as below
iris[1:4] %>% map_dbl(function(x) if(is.numeric(x)) sum(x))
Depends on intended output. The map functions always return a list or vector of the same length as input, so summarise is a better option if you want to leave one column out.
If you want to keep the Species column, just not summed, you can do iris %>% map_if(is.numeric, sum)