[R] read.table() features {was "difficult data .."}
Martin Maechler
maechler at stat.math.ethz.ch
Tue Jul 4 12:23:17 CEST 2006
>>>>> "Gabor" == Gabor Grothendieck <ggrothendieck at 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
More information about the R-help
mailing list