Skip to content

type.convert() does not treat "NA" as ordinary string as intended from version 1.5 (PR#1567)

1 message · Jens Oehlschlägel

#
# replication code at end of mail
[1] FALSE
[1] NA  1 NA
[1] NN   1    <NA>
Levels:  1 NN NA
[1] NA  1 NA
[1] NN   1    <NA>
Levels:  1 NN NA 
 
 
# furthermore, may be type.convert should have default
# function(x, na.strings = NA, as.is = FALSE, dec = ".")
# or 
# function(x, na.strings = character(), as.is = FALSE, dec = ".")
# or 
# function(x, na.strings = NULL, as.is = FALSE, dec = ".")
# rather then
# function(x, na.strings = "NA", as.is = FALSE, dec = ".")


# As from R 1.5 

identical(as.character(NA), "NA")

# there is no longer a fundamental difference between "NA" 
# and an ordinary string like "NN" (WHICH IS A GREAT IDEA!!)
# however, though "NA" is not given as na.strings we have

type.convert(c("NA", "1", NA), na.strings="b")
# compare to
type.convert(c("NN", "1", NA), na.strings="b")

# dito
type.convert(c("NA", "1", NA), na.strings=character())
# compare to
type.convert(c("NN", "1", NA), na.strings=character())