Bug 16275 - read.fortran doesn't recognise D format
Summary: read.fortran doesn't recognise D format
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: I/O (show other bugs)
Version: R 3.0.2
Hardware: x86_64/x64/amd64 (64-bit) Windows 64-bit
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-03-20 14:38 UTC by James
Modified: 2015-03-20 14:38 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James 2015-03-20 14:38:17 UTC
?read.fortran states that:

The format for a field is of one of the following forms: rFl.d, rDl.d, rXl, rAl, rIl...

However, when trying to use the "D" format the following error and warnings are given:

read.fortran(textConnection("1.23e4"),format="D6")
Error in processFormat(format) : missing lengths for some fields
In addition: Warning messages:
1: In processFormat(format) : NAs introduced by coercion
2: In processFormat(format) : NAs introduced by coercion
3: In processFormat(format) : NAs introduced by coercion

The template definition in line 5 of read.format seems to be where the problem lies,

        template <- "^([0-9]*)([FXAI])([0-9]*)\\.?([0-9]*)"

This can be simply fixed by changing it to,

        template <- "^([0-9]*)([FDXAI])([0-9]*)\\.?([0-9]*)"

as the rest of the code is written to deal with "D". Indeed it can be confirmed:

read.fortran2(textConnection("1.23e4"),format="D6")
     V1
1 12300

However, this still doesn't allow Fortran double precision formatted numbers to be read:

read.fortran2(textConnection("1.23D4"),format="D6")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  scan() expected 'a real', got '1.23D4'