Re: [R] Reading a file created with Fortran

From: Mike Prager <mike.prager_at_noaa.gov>
Date: Wed, 27 Feb 2008 16:43:38 -0500

Ben Bolker <bolker_at_ufl.edu> wrote:

> Dennis Fisher <fisher <at> plessthan.com> writes:

> > I am trying to read a file written by Fortran. Several lines of the
> > file are pasted below:
>
> Perhaps read.fwf is what you want? (fwf stands for
> "fixed width format"). You would have to work out the
> field widths, but it would seem to be pretty straightforward).

A couple of points. First, since you know the format statement, perhaps you control the Fortran program. Then, it might be nicer to introduce whitespace between the data items, which would serve two purposes: making read.table() work on the data set and making it easier for humans to check the data file more easily.

Second, you could look at read.fortran() -- a function that takes a lightly modified Fortran format specification as an argument. That seems even better for your purposes than read.fwf.

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

______________________________________________
R-help_at_r-project.org 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.
Received on Wed 27 Feb 2008 - 21:46:01 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 27 Feb 2008 - 22:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive