2

How can I de-select a column named "(Intercept)" using dplyr::select and not using the column-index?

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

Thanks&kind regards

r.user.05apr
  • 5,356
  • 3
  • 22
  • 39

1 Answers1

5

We need to use backquotes

tib %>% 
    select(-`(Intercept)`)
tib %>% 
    select(`(Intercept)`)
akrun
  • 874,273
  • 37
  • 540
  • 662