[R] Reading fixed column format

Gabor Grothendieck ggrothendieck at gmail.com
Wed Sep 13 19:02:57 CEST 2006


On 9/13/06, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> On 9/13/06, Anupam Tyagi <AnupTyagi at yahoo.com> wrote:
> > Gabor Grothendieck <ggrothendieck <at> gmail.com> writes:
> >
> > > C:\bin>cut -c2-3,6-8 a.dat
> > > 23678
> > > 23678
> > > 23678
> >
> > Thanks. I think this will work. How do I redirect the output to a file on
> > windows?
>
> Same as on UNIX
>
> cut -c2-3,6-8 a.dat > a2.dat
>
> > Is there simple way to convert the cut command to a script on windows,
>
> Using notepad or other text editor put it in file a.bat and then
> issue this command from the console
>
> a.bat
>
> Note that you could process it multiple time if you like:
>
> cut -c6-8 a.dat > a2.dat
> cut -c2-3 a2.dat > a3.dat

Sorry that's wrong.  It should be:

cut -c2-3 a.dat > a1.dat
cut -c6-8 a.dat > a2.dat

Now read in each of the files, a1.dat, a2.dat into R.


>
> produces the same thing but uses 2 passes and so keeps each line shorter.
> Be sure you do it from the tail end forward as shown above to avoid having
> to recalculate the positions.
>
> > because the entire command may not fit on one line? Anupam.
> >
>



More information about the R-help mailing list