I want to import an XLSX spreadsheet containing also columns that are dates. The problem is to find a 'simple' way to import those dates correctly, since guessing the column types fails to do the job.
I tried to subset the col_types argument to effect only specific columns (those with the dates) and guess all others, but found no solution.
I ended up subsetting the imported spreadsheet into columns with data and all other columns and, in a second step, binding them together using this code structure:
df <- bind_cols(
read_xlsx("DATA.xlsx",
range = "C:F",
col_types = "date"),
read_xlsx("DATA.xlsx") %>%
select(!c(3:6))
)
This, however, changes the column order, that has to be fixed afterwards.
Is there a simpler solution, like subsetting the col_types argument (and maintain original column order)?