Perhaps this has to do with the fact that there is not enough information available to establish the class of those columns. For example, try this:
read.table("clipboard", colClasses = "character") On 5/9/07, John Fox <[EMAIL PROTECTED]> wrote: > Dear r-devel list members, > > I stumbled across the following behaviour of read.table() recently: Suppose > that I have the data > > a " " "" > "" "" "" > > in a file or copied to the clipboard, and issue the command > > > DF <- read.table("clipboard") > > DF > V1 V2 V3 > 1 a NA NA > 2 NA NA > > > is.na(DF) > V1 V2 V3 > [1,] FALSE TRUE TRUE > [2,] FALSE TRUE TRUE > > I was surprised by the NAs. Note that they occur only when a column consists > entirely of empty strings or strings composed of blanks. > > On the other hand > > > data.frame(A=c("", "", "")) > A > 1 > 2 > 3 > > works as I would have expected. > > A work-around for me was > > > DF[is.na(DF)] <- "" > > DF > V1 V2 V3 > 1 a > 2 > > But, as I said, I found the behaviour of read.table() puzzling. > > All this is with R 2.5.0 on a Windows XP Pro SP 2 system. > > Comments? > > Thanks, > John > > -------------------------------- > John Fox, Professor > Department of Sociology > McMaster University > Hamilton, Ontario > Canada L8S 4M4 > 905-525-9140x23604 > http://socserv.mcmaster.ca/jfox > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel