I have a column which has dates in Excel's internal format. The Excel file comes from someone's reporting software, so I can't just format the column in Excel (unless I want to do it every time I get an update).
| ◢ |
Date |
| 1 |
39448 |
| 2 |
39449 |
| 3 |
39450 |
date_test.xlsx
These should map to the first, second, and third of January 2008.
> as.Date(read_excel("../notes/date_test.xlsx")$Date, origin="1899-12-30")
[1] "2008-01-01" "2008-01-02" "2008-01-03"
But if I tell read_excel that it's a date:
z <- read_excel("../notes/date_test.xlsx", col_types="date")
Warning messages:
1: In read_xlsx_(path, sheet, col_names = col_names, col_types = col_types, :
[2, 1]: expecting date: got '39448'
2: In read_xlsx_(path, sheet, col_names = col_names, col_types = col_types, :
[3, 1]: expecting date: got '39449'
3: In read_xlsx_(path, sheet, col_names = col_names, col_types = col_types, :
[4, 1]: expecting date: got '39450'
> z
Date
1 <NA>
2 <NA>
3 <NA>
I have a column which has dates in Excel's internal format. The Excel file comes from someone's reporting software, so I can't just format the column in Excel (unless I want to do it every time I get an update).
date_test.xlsx
These should map to the first, second, and third of January 2008.
But if I tell
read_excelthat it's a date: