On Tue, 29 May 2007, Tobin, Jared wrote: > Hello, > > I am trying to figure out if there exists some R command that allows one > to be > particularly selective when reading a file. I'm dealing with large > fixed-width data > sets that look like > > 539001.. > 639001.. > 639001.. > ... > 539002.. > 639002.. > ... > > Presently, I am using read.fwf to read an entire file, but I am > interested only in > reading those records beginning with 5. I have been unable to find help > in any of > the suggested resources.
Assuming you have 'grep' in your path, res <- read.fwf( pipe( "grep '^5' my.file" ) , <other args> ) will do it. grep will usually be found on linux/unix systems and Mac OS X. The 'Rtools' toolkit for windows has grep, I believe. > > I understand this is a SAS example that replicates what I'm looking to > do, if it's of > any help to anyone. > > street type name am > traffic pm traffic > > freeway 408 3684 > 3459 > surface Martin Luther King Jr. Blvd. 1590 1234 > freeway 608 4583 > 3860 > freeway 808 2386 > 2518 > surface Lake Shore Dr. 1590 1234 > > INPUT type $ @; > IF type = 'surface' THEN DELETE; > INPUT name $ 9-38 amtraff pmtraff; > > Any answers, suggestions, or points-in-the-right-direction would be much > appreciated. > > -- > > Jared Tobin, Student Research Assistant > Dept. of Fisheries and Oceans > [EMAIL PROTECTED] > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > 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. > Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0901 ______________________________________________ R-help@stat.math.ethz.ch mailing list 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.