r - Select columns using select_ in dplyr when column names have brackets -


in data frame, column names have brackets. want use function select_ pick columns need.

however, got error message

error in overscope_eval_next(overscope, expr) : object 'a.b.v1' not found 

how solve problem?

this minimumal example reproduce problem.

library(dplyr)  <- data_frame(`a.b.v1:7(1)` = seq(1, 10), b = seq(1, 10)) # can select 1 column %>% select(`a.b.v1:7(1)`) # cannot select columns col <- c('a.b.v1:7(1)', 'b') %>% select_(.dots = col) 

you can use backquotes, eg:

col <- c('`a.b.v1:7(1)`', 'b') %>% select_(.dots = col)  # tibble: 10 x 2 `a.b.v1:7(1)`     b <int> <int> 1             1     1 2             2     2 3             3     3 4             4     4 5             5     5 6             6     6 7             7     7 8             8     8 9             9     9 10            10    10 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -