Named colClasses doesn't work
According to documentation:
https://www.rdocumentation.org/packages/xlsx/versions/0.6.5/topics/read.xlsx

Here is my simple test xlsx file:

- Without
colClasses:
> META <- xlsx::read.xlsx('1.xlsx', sheetIndex = 1)
> str(META)
'data.frame': 1 obs. of 3 variables:
$ A: chr "ABC"
$ B: Date, format: "1970-01-01"
$ C: num 2000
- With all classes described:
> META <- xlsx::read.xlsx('1.xlsx', sheetIndex = 1, colClasses = c(A = "character", B = "Date", C = 'character'))
> str(META)
'data.frame': 1 obs. of 3 variables:
$ A: chr "ABC"
$ B: Date, format: "1970-01-01"
$ C: chr "0000"
- Looks like all good, but if you remove first class
F = "character":
> META <- xlsx::read.xlsx('1.xlsx', sheetIndex = 1, colClasses = c(B = "Date", C = 'character'))
> str(META)
'data.frame': 1 obs. of 3 variables:
$ A: Date, format: NA
$ B: chr "0"
$ C: num 2000
Warning message:
In as.POSIXlt.Date(x) : NAs introduced by coercion
colClasses doesn't respect names - only position in vector.
Thanks for the great reprex! This should make it much easier to isolate and fix (although I haven't looked to see how complex a fix is).
Just for future reference on other projects, the reprex package can provide even more simple "copy and use" examples. It's a bit tricky with the xlsx package, but the way we do it in our tests is often to write out the file in question to a temp file and then import it.
@colearendt Hello, I see that xlsx package doesn't receive any updated for long time, do you have any fix for this problem?