Hi all,

Apparently, the colClasses argument to read.table needs to be in the
order of the columns *even when it is named*.  Why is that?  And where
would I find it in the documentation?

Here is a MWE:

--8<---------------cut here---------------start------------->8---
kkk <- c("a\tb",
         "3.14\tx")
read.table(textConnection(kkk),
           sep="\t",
           header = TRUE)

cclasses=c(b="character",
           a="numeric")

read.table(textConnection(kkk),
           sep="\t",
           header = TRUE,
           colClasses = cclasses)              ## <--- error

read.table(textConnection(kkk),
           sep="\t",
           header = TRUE,
           colClasses = cclasses[order(names(cclasses))])
--8<---------------cut here---------------end--------------->8---


Thanks,
Andreas

______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to