AW: [R] read.table problems

Kurt Hornik Kurt.Hornik@ci.tuwien.ac.at
Mon, 15 Nov 1999 13:50:08 +0100 (CET)


>>>>> =?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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._