Reputation: 13852
I have an Excel spreadsheet called "my_data". I can recreate the spreadsheet in R as follows:
library(tibble); library(readxl)
tibble(x = c(1L, 2L, 3L), y = c("A", "B", "C")) -> my_data
On import, I can specify column types like this:
read_excel("/Desktop/my_data.xlsx", col_types = c("numeric", "text") -> my_data
But the vector supplied to col_types
needs to be in the same order as my spreadsheet to give correct results. If I move the order of columns in the spreadsheet or add/delete columns, col_types
will be wrong.
Can I supply the column types for specific columns and leave read_excel to guess the types for the rest of the columns?
Upvotes: 1
Views: 40