openxlsx icon indicating copy to clipboard operation
openxlsx copied to clipboard

Documentation doesn't match functionality in `read.xlsx` for `na.strings`

Open Moohan opened this issue 1 year ago • 1 comments

The default for na.strings is "NA" but the documentation says:

A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.

read.xlsx actually does both, for example in this workbook: Book1.xlsx The columns have blank "", literal NA "NA" and Excel type NA #N/A but read.xlsx will read them all as NA.

openxlsx::read.xlsx("Book1.xlsx")
#>   var test1 test2
#> 1   1     a  <NA>
#> 2   2  <NA>  <NA>
#> 3   3     b     c
#> 4   4     c     a

Created on 2023-03-21 with reprex v2.0.2

From the documentation, I would have expected only the blanks "" to be read as NA.

Not sure if this is a bug or if the documentation needs updating.

Moohan avatar Mar 21 '23 12:03 Moohan