Re: [R] Reading a file created with Fortran

2008-02-27 Thread Mike Prager
Ben Bolker <[EMAIL PROTECTED]> wrote:

> Dennis Fisher  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@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.


Re: [R] Reading a file created with Fortran

2008-02-26 Thread Dieter Menne
Ben Bolker  ufl.edu> writes:


>   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 little bit of extra verbiage will make gmane happier ...]
> 
>   Ben Bolker

True, gmane is a bit too strict, but overall it would help improve the 
clarity if everyone in R-help would use gmane. 

(To the non-gmanians): the gmane interface to R-help

http://news.gmane.org/gmane.comp.lang.r.general

simply refuses to post messages with high quoted/reply ratio.

Dieter

__
R-help@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.


Re: [R] Reading a file created with Fortran

2008-02-26 Thread Ben Bolker
Dennis Fisher  plessthan.com> writes:

> 
> Colleagues,
> 
> 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 little bit of extra verbiage will make gmane happier ...]

  Ben Bolker

__
R-help@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.


[R] Reading a file created with Fortran

2008-02-26 Thread Dennis Fisher
Colleagues,

I am trying to read a file written by Fortran.  Several lines of the  
file are pasted below:

101   06e+050280.9777.484208.18147.20.246350.4020.7308717.882600 1 1
101 0.500280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101   100280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101 1.500280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101   200280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101 2.500280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101   300280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101   400280.9777.484208.18147.20.246350.4020.7308717.882600 0 0
101   600280.9777.484208.18147.20.246350.4020.7308717.882600 0 0

The fortran format statement is:
(E3.0,E4.0,E5.0,E1.0,3E6.0,E5.0,E7.0,E5.0,E7.0,E6.0,E3.0,2F2.0)

The read.table command cannot parse the table correctly because there  
are no spaces between columns.  Although readLines reads the file, it  
does not separate the elements into columns.  I suspect that the  
"what" option of "scan" accomplishes my intent although its  
implementation is poorly document in help (or perhaps I am too dense  
to understand it).

Can anyone advise as to an efficient means to read these data and  
separate into columns?

Thanks.

Dennis


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-415-564-2220
www.PLessThan.com


[[alternative HTML version deleted]]

__
R-help@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.