\Header{read.fwf}{Read Fixed Width Format Files}
\keyword{file}{read.fwf}
\keyword{connection}{read.fwf}
\begin{Description}\relax
Read a ``table'' of \bold{f}ixed \bold{w}idth \bold{f}ormatted data
into a \code{\Link{data.frame}}.\end{Description}
\begin{Usage}
\begin{verbatim}
read.fwf(file, widths, sep = "\t", as.is = FALSE,
         skip = 0, row.names, col.names, n = -1, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{file}] the name of the file which the data are to be read from.

Alternatively, \code{file} can be a \code{\Link{connection}}, which
will be opened if necessary, and if so closed at the end of the
function call.

\item[\code{widths}] integer vector, giving the widths of the fixed-width
fields (of one line).
\item[\code{sep}] character; the separator used internally; should be a
character that does not occur in the file.
\item[\code{as.is}] see \code{\Link{read.table}}.
\item[\code{skip}] number of initial lines to skip; see
\code{\Link{read.table}}.
\item[\code{row.names}] see \code{\Link{read.table}}.
\item[\code{col.names}] see \code{\Link{read.table}}.
\item[\code{n}] the maximum number of records (lines) to be read, defaulting
to no limit.
\item[\code{...}] further arguments to be passed to
\code{\Link{read.table}}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Fields that are of zero-width or are wholly beyond the end of the line
in \code{file} are replaced by \code{NA}.\end{Details}
\begin{Value}
A \code{\Link{data.frame}} as produced by \code{\Link{read.table}}
which is called internally.\end{Value}
\begin{Author}\relax
Brian Ripley for \R{} version: original \code{Perl} by Kurt Hornik.\end{Author}
\begin{SeeAlso}\relax
\code{\Link{scan}} and \code{\Link{read.table}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
ff <- tempfile()
cat(file=ff, "123456", "987654", sep="\n")
read.fwf(ff, width=c(1,2,3))    #> 1 23 456 \ 9 87 654
unlink(ff)
cat(file=ff, "123", "987654", sep="\n")
read.fwf(ff, width=c(1,0, 2,3))    #> 1 NA 23 NA \ 9 NA 87 654
unlink(ff)
\end{ExampleCode}
\end{Examples}

