Selecting specific columns of an excel sheet with read_excel

Hi,

I am trying to import data from a huge Excel file using the readxl package. I want to select only certain columns and cells of the Excel file using the following code:

library(readxl)
XYZ <- read_excel("XYZ.xlsx", sheet = "Quarterly Series", range = c("A372:A378", "BL372:BL378", "CF372:CF378", "DX372:DX378"), col_types = c("date", "numeric", "numeric", "numeric"), col_names = c("date", "Germany", "France", "Italy"))

Unfortunately I always get the error message "Error in as.cell_limits.character(range) : length(x) == 1L is not TRUE". What is the problem with my code or is there a better approach to select certain columns of an Excel file?

Thanks

I think your issue is that range param is not vectorise, so it will take a single range value.
so maybe you would construct several read_excel calls, each one covering contigious block ranges that you want to read, and combine those df's together.

or rearrange the excel files so all columns that should be imported are located together.