How to avoid readxl using ..1, ..2 as variable names

Looking at the readxl documentation, I can see, that default column names, when there are no column names, has recently changed to ..1, ..2, ..3, etc.

This creates some troubles, as illustrated here

library('readxl')
d = read_excel(readxl_example("datasets.xlsx"), skip = 148, col_names = FALSE)
# New names:                                                                                                                                                                                                                                                 
# * `` -> `..1`
# * `` -> `..2`
# * `` -> `..3`
# * `` -> `..4`
# * `` -> `..5`
d %>% select(..1)
# Error in .f(.x[[i]], ...) : 
#   ..1 used in an incorrect context, no ... to look in
d %>% select(`..1`)
# Error in .f(.x[[i]], ...) : 
#   ..1 used in an incorrect context, no ... to look in

I can naturally do something like this:

colnames(d) = colnames(d) %>% str_replace("..", "X")
d
# # A tibble: 3 x 5
#      X1    X2    X3    X4 X5       
#   <dbl> <dbl> <dbl> <dbl> <chr>    
# 1   6.5   3     5.2   2   virginica
# 2   6.2   3.4   5.4   2.3 virginica
# 3   5.9   3     5.1   1.8 virginica

But I'd rather not do this every time I read an excel file, so how to avoid readxl using ..1, ..2 as variable names?

@mara replied in a similar thread:

1 Like

Yup, just in case people don't click over to that thread, here's the GH issue in the repo:

Ok, so it's a bug - Makes sense. Hopefully it'll be rectified in a near future, I had a bunch of code breaking down because of this :bug:

Bw. Leon

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.