Vadim Ogranovich
2002-Nov-27 21:37 UTC
[R] read.table: colClasses when num. of columns is unknown
Hi, I am looking for a way to read tables that have general structure of characterTag num1 num2 ... i.e. one character column followed by an unknown to the caller (but fixed throughout the file) number of numeric columns. I wanted to improve the speed of read.table by using colClasses, but that seemed to require knowledge of the actual number of columns in the file. For example I tried colClasses=c("character", rep("numeric", 100)), here 100 is an upper boundary on the number of columns, and hoped read.table() would just ignore the unused entries. But read.table failed and printed an error message (proving once again that R is a production-strength software). Is there any way around? Note that my files do have headers so the number of columns should be known to read.table once it parses the header. Thanks, Vadim -------------------------------------------------- DISCLAIMER This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately notify me and permanently delete the original and any copy of any e-mail and any printout thereof. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. NOTICE regarding privacy and confidentiality Knight Trading Group may, at its discretion, monitor and review the content of all e-mail communications. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk
2002-Nov-27 22:29 UTC
[R] read.table: colClasses when num. of columns is unknown
On Wed, 27 Nov 2002, Vadim Ogranovich wrote:> Hi, > > I am looking for a way to read tables that have general structure of > > characterTag num1 num2 ... > > i.e. one character column followed by an unknown to the caller (but fixed > throughout the file) number of numeric columns. I wanted to improve the > speed of read.table by using colClasses, but that seemed to require > knowledge of the actual number of columns in the file. For example I tried > colClasses=c("character", rep("numeric", 100)), here 100 is an upper > boundary on the number of columns, and hoped read.table() would just ignore > the unused entries. But read.table failed and printed an error message > (proving once again that R is a production-strength software). > Is there any way around? Note that my files do have headers so the number of > columns should be known to read.table once it parses the header.So read it yourself with readLines and push the header back. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help 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-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._