## Read Fixed-Format Data in a Fortran-like Style

### Description

Read fixed-format data files using Fortran-style format specifications.

### Usage

read.fortran(file, format, ..., as.is = TRUE, colClasses = NA)


### Arguments

 file File or connection to read from. format Character vector or list of vectors. See ‘Details’ below. ... Other arguments for read.fwf. as.is Keep characters as characters? colClasses Variable classes to override defaults. See read.table for details.

### Details

The format for a field is of one of the following forms: rFl.d, rDl.d, rXl, rAl, rIl, where l is the number of columns, d is the number of decimal places, and r is the number of repeats. F and D are numeric formats, A is character, I is integer, and X indicates columns to be skipped. The repeat code r and decimal place code d are always optional. The length code l is required except for X formats when r is present.

For a single-line record, format should be a character vector. For a multiline record it should be a list with a character vector for each line.

Skipped (X) columns are not passed to read.fwf, so colClasses, col.names, and similar arguments passed to read.fwf should not reference these columns.

A data frame

### Note

read.fortran does not use actual Fortran input routines, so the formats are at best rough approximations to the Fortran ones. In particular, specifying d > 0 in the F or D format will shift the decimal d places to the left, even if it is explicitly specified in the input file.

read.fwf, read.table, read.csv

### Examples

ff <- tempfile()
cat(file = ff, "123456", "987654", sep = "\n")