[R] problem formatting data frames
macq at llnl.gov
Wed Jul 17 19:58:21 CEST 2002
Have you looked at the help page for read.table, and noticed the
comment.char and colClasses arguments?
If the rows of text have sufficient consistency you might be able to
use comment.char option.
You could try the colClasses option to force it to read the columns
as numerical, in which case the non-numeric data should be coerced to
If you are on a unix machine, or have a windows machine with unix
tools installed, you could use pipe() to pipe the files through, for
example, a sed script that tosses any rows with non-numeric
characters (other than 'E' if there is any data formatted in
At 10:01 AM -0400 7/17/02, VBMorozov at lbl.gov wrote:
> Dear R-guRus:
>I have a problem with the format of my data in R.
>Let's say I have a HUGE text table which consists of columns of
>numerical data, separated by tabs, but in some places rows of text
>(error messages, etc) are inserted in between rows of numerical data.
>Because the data file is so huge and because I have thousands of these
>files, it's unpractical to try and go thru these files manually and
>remove text rows - I'd like R to do it for me.
>The following command works:
>but instead of numerical data in my frame I get "factor" data, because
>of these text inserts. How do I filter them out??
>Thank you very much,
>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
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
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
More information about the R-help