如何使用dplyr :: select取消选择名为“(Intercept)”的列而不使用列索引?
library(dplyr)
library(tibble)
tib<-tribble(~"(Intercept)",~b,
80,3,
80,4,
80,4)
tib[,-1] # works
select(tib,eval(parse(("-(Intercept)")))) # does not work
select(tib,as.name(("-(Intercept)"))) # does not work
select(tib,-"\(Intercept\)") # does not work
谢谢和亲切的问候
答案 0 :(得分:1)
我们需要使用反引号
tib %>%
select(-`(Intercept)`)
tib %>%
select(`(Intercept)`)