I need to select all columns that are not numeric. I can select all numeric columns easily using select_if
:
mtcars %>% select_if(is.numeric)
What if I want to select non-numeric
columns? I tried:
mtcars %>% select_if(!is.numeric)
But I got error message below:
Error in !is.numeric : invalid argument type
Thanks a lot for help!
You can use purrr
's negate()
which is included if you use library(tidyverse)
rather than just library(dplyr)
library(tidyverse)
iris %>% select_if(negate(is.numeric))
[dbther]
欢迎光临 OStack程序员社区-中国程序员成长平台 (http://ostack.cn/) | Powered by Discuz! X3.4 |