\Header{write}{Write data to a file}
\keyword{file}{write}
\begin{Usage}
\begin{verbatim}
write(x, file="data",
        ncolumns=if(is.character(x)) 1 else 5,
        append=FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{x}] the data to be written out.
\item[\texttt{file}] the name of the file (quoted) to write to.
\item[\texttt{ncolumns}] the number of columns to write the data in.
\item[\texttt{append}] if \texttt{TRUE} the data \texttt{x} is appended to file \texttt{file}.
\end{ldescription}
\end{Arguments}
\begin{Description}
The data (usually a matrix) \texttt{x} are written to file \texttt{file}.
If \texttt{x} is a two dimensional matrix you need to transpose it to get the
columns in \texttt{file} the same as those in the internal representation.\end{Description}
\begin{SeeAlso}
\texttt{\Link{scan}} for reading data.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# create a 2 by 5 matrix
x <- matrix(1:10,ncol=5)

# the file data contains x, two rows, five cols
# 1 3 5 6 9 will form the first row
write(t(x))

# the file data now contains the data in x,
# two rows, five cols but the first row is 1 2 3 4 5
write(x)
\end{ExampleCode}
\end{Examples}

