[R] Read FWF, problem and solution?

Jason Turner jasont at indigoindustrial.co.nz
Thu Dec 12 21:37:03 CET 2002


On Thu, Dec 12, 2002 at 09:23:10AM -0800,  Brett Magill wrote:
...
> Using read.fwf, I tried to open a fixed-width file that of about 4 MB residing
> in the working directory, using the command below:
> 
>   dat<-read.fwf("sc01aai.dat", widths=fields$length)
> 
> where fields$lengths is a vector of column widths, 28 to be exact.  The data
> are a mix of character, text, and factor variables.
> 
> R started processing and continued doing so for more than an hour and a half
> before I returned and stopped it.  It was obviously still working, CPU,
> memory, and swap space all ablaze.
...

4MB and 28 cols would be a non-trivial number of rows.  Not enourmous,
but non-trivial.  For jobs like this, scan() is my preferred method
(for enormous jobs, I load the data into a proper database server - 
e.g. PostgreSQL, MySQL, Oracle, MS SQL server, etc - and load into
R from there).

So - scan() is your friend.

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
64-21-343-545
jasont at indigoindustrial.co.nz




More information about the R-help mailing list