[R] read.table() features {was "difficult data .."}

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Tue 04 Jul 2006 - 20:23:17 EST

>>>>> "Gabor" == Gabor Grothendieck <ggrothendieck@gmail.com>
>>>>> on Mon, 3 Jul 2006 16:58:14 -0400 writes:

    Gabor> Try this:

    Gabor> # test data
    Gabor> # read in header separately so R does not make column names unique

    Gabor> Lines <- "AAA BBB CCC DDD AAA BBB
    Gabor> 0      2      1     2      0      0
    Gabor> 2      3      7     6      0      1
    Gabor> 1.5    4      9     9      6      0
    Gabor> 1.0    6      10    11     3      3
    Gabor> "
    Gabor> DF <- read.table(textConnection(Lines), skip = 1)
    Gabor> names(DF) <- scan(textConnection(Lines), what = "", nlines = 1)

Hmm, this is unnecessarily slightly complicated. Instead, rather make use of read.table()'s capabilities, by

   DF <- read.table(textConnection(Lines), check.names=FALSE, header=TRUE)
   ##                                      ^^^^^^^^^^^^^^^^^

Martin Maechler, ETH Zurich



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jul 04 20:34:49 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 04 Jul 2006 - 22:15:30 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.