[R] skipping columns with read.fwf?

Pierre Kleiber pkleiber at honlab.nmfs.hawaii.edu
Fri May 3 21:11:59 CEST 2002


If you are in a Unix-like environment, you can use awk to preselect
the columns you want as follows:

read.table(pipe("awk '{print $1,$3,$4,$5,$6,$7,$8,$25,$26,$27,$40}' fwf"))

  Cheers, Pierre


Brett A Magill wrote:
> I have a file in fwf.  It is rather large, about 40,000 rows and 40 variables (columns).  I only need about 10 variables form the data set for the analysis at hand.  Unfortunately, these 10 variables are not contiguous in the file, for example, the first is position 1-8, the next position 25-27, then 40.
> 
> Is there a way to read the selected varaibles that I need without reading in the entire data set?
> 
> Thanks,
> 
> Brett    
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 



-- 
-----------------------------------------------------------------
Pierre Kleiber             Email: pkleiber at honlab.nmfs.hawaii.edu
Fishery Biologist                     Tel: 808 983-5399/737-7544
NOAA FISHERIES - Honolulu Laboratory         Fax: 808 983-2902
2570 Dole St., Honolulu, HI 96822-2396
-----------------------------------------------------------------
  "God could have told Moses about galaxies and mitochondria and
   all.  But behold... It was good enough for government work."
-----------------------------------------------------------------


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