I have a df as follows:
a <- data_frame(keep=c("hello", "world"),drop = c("nice", "work"))
a
Source: local data frame [2 x 2]
keep drop
(chr) (chr)
1 hello nice
2 world work
I can use a %>% select(-drop)
to drop the column without problem. however, if I want to pass a variable to present drop
column, then it returns error.
name <- "drop"
a %>% select(-(name))
See Question&Answers more detail:osError in -(name) : invalid argument to unary operator