[Rd] read.table (PR#1227)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Wed, 26 Dec 2001 00:04:21 +0100 (MET)


The main point is already fixed in R-patched.

On Tue, 25 Dec 2001 possolo@crd.ge.com wrote:

> Full_Name: Antonio Possolo
> Version: 1.4.0
> OS: Linux
> Submission from: (NULL) (24.25.141.205)
>
>
> ## inputFile has the following three lines (each without the initial ``## '')
> ## a,b
> ## m,1
> ## n,3
> ## and resides in $HOME/R
>
> fileHOME <- paste(Sys.getenv("HOME"), "/R/", sep="")
> fileNAME <- "inputFile"
>
> ## Given the command,
>
> z <- read.table(file=paste(fileHOME, fileNAME, sep=""), sep=",",
>                 header=TRUE, row.names=NULL, as.is=TRUE)
>
> ## R replies
>
> ## stack imbalance in internal type.convert,
> ##   28 then 27stack imbalance in .Internal, 27 then 26
> ## stack imbalance in if, 21 then 20
> ## stack imbalance in <-, 19 then 18
> ## stack imbalance in {, 17 then 16
> ## stack imbalance in for, 10 then 9
> ## stack imbalance in {, 8 then 7
> ## stack imbalance in <-, 2 then 1
> ## Error: unprotect(): stack imbalance
>
> ## but z is correct.
>
> ## The command
>
> z <- read.table(file=paste(fileHOME, fileNAME, sep=""), sep=",",
>                            header=TRUE, row.names=NULL, as.is=TRUE,
>                            colClasses=c("character", "numeric"))
>
> ## produces the same result without complaints.

Yes, and as this is much preferable, the previous case never got
tested!  Leave as.is= out ...

> ## Finally, the command
>
> z <- read.table(file=paste(fileHOME, fileNAME, sep=""), sep=",",
>                            header=TRUE, row.names=NULL, as.is=FALSE)
>
> ## also produces a data-frame with the correct elements,
> ## but z$a is a factor, not a character vector.

If as.is=FALSE, character inputs are documented to be converted to
factors, so where is the bug?

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._