From Kurt.Hornik@ci.tuwien.ac.at  Mon Nov 15 12:50:08 1999
From: Kurt.Hornik@ci.tuwien.ac.at (Kurt Hornik)
Date: Mon, 15 Nov 1999 13:50:08 +0100 (CET)
Subject: AW: [R] read.table problems
In-Reply-To: <000201bf2c7d$e05bccf0$a9021aac@joelschlaegel>
References: <199911101403.JAA24560@sirocco.cc.mcgill.ca>
 <000201bf2c7d$e05bccf0$a9021aac@joelschlaegel>
Message-ID: <14384.384.648411.991018@fangorn.ci.tuwien.ac.at>

>>>>> =?iso-8859-1?Q?Jens Oehlschl=E4gel-Akiyoshi?= writes:

> Below is a fix for read.table() to better read in CSV-files.

>> # try this
>> cat("1;2,3\n4;5,6\n", file="d:/temp/t.dat")
>> system("cat d:/temp/t.dat", show=TRUE)
> 1;2,3
> 4;5,6
>> read.table("d:/temp/t.dat", sep=";", dec.sep=",")
>   V1  V2
> 1  1 2.3
> 2  4 5.6

I am not sure we should do this.

If you are trying to read in German-format numbers, this should be
doable by setting the locale accordingly.  Does anyone know whether
strtod() will work this way?

> BTW: I think read.table() or it's documentation needs another fix,
>      because of the following:


>> cat("1 2\n3 4\n", file="d:/temp/t.dat")
>> system("cat d:/temp/t.dat", show=TRUE)
> 1 2
> 3 4
>> read.table("d:/temp/t.dat", as.is=TRUE)$V1
> [1] "1" "3"


> Citing from the help file:

>       as.is: the default behavior of `read.table' is to convert
>              non-numeric variables to factors.  The variable
>              `as.is' controls this conversion.  Its value is
>              either a vector of logicals (values are recycled
>              if necessary), or a vector of numeric indices
>              which specify which columns should be left as
>              character strings.

Fixed.

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


AW: [R] read.table problems
Kurt Hornik