I'd like to import a dataset from Excel. I need to import the variables which contains the word "DATE" as col_types = "date"
. If I set col_types = "date"
for all the data, the variables which aren't dates are filled with NA
. I'd like to set a condition on that option (col_types
). I used the next code:
base <- read_xlsx("C:/Users/.../base.xlsx", col_types = "date")
CodePudding user response:
You can try to first read the whole spreadsheet and hence to select the wanted columns:
library(tidyverse)
read_xlsx("C:/Users/.../base.xlsx", col_types = "date") %>%
select(contains("DATE"))