[R] problem formatting data frames

Andrew C. Ward andreww at cheque.uq.edu.au
Thu Jul 18 03:46:11 CEST 2002


Hello Vlad,

I usually don't get R to do anything like this for me, and prefer
preparing the data using GNU awk or something similar. awk
or gawk are available for many different operating systems,
including Unix, Linux, and Windows.

I would usually use something like
    gawk ' BEGIN {FS="\t"} {if (NF==8) print $0 } ' file.dat
which only displays lines with 8 tab-separated fields. More
advanced users of R than I am undoubtedly know how to
effect the same thing using scan or read.table.

Regards,

Andrew C. Ward

CAPE Centre,
The University of Queensland
Brisbane Qld 4072 Australia
andreww at cheque.uq.edu.au

----- Original Message -----
From: <VBMorozov at lbl.gov>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, July 18, 2002 12:01 AM
Subject: [R] problem formatting data frames


>
>  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:
>
> MyDataFrame<-data.frame(read.table("MyFile"))
>
> 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,
> Vlad.
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-
> 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
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 mailing list