[R] read.table and NaN

Sebastien Bihorel Seb@@t|en@B|hore| @end|ng |rom cogn|gencorp@com
Thu Oct 24 03:31:21 CEST 2019


Hi,

Is there a way to make read.table consider NaN as a string of characters rather than the internal NaN? Changing the na.strings argument does not seems to have any effect on how R interprets the NaN string (while is does not the the NA string)

con <- textConnection(object = 'A,B\n1,NaN\nNA,2')
tmp <- read.table(con, header = TRUE, sep = ',', na.strings = '', stringsAsFactors = FALSE)
close.connection(con)
tmp
class(tmp[,1])
class(tmp[,2])




More information about the R-help mailing list