\HeaderA{write.dbf}{Write a DBF File}{write.dbf}
\keyword{file}{write.dbf}
\begin{Description}\relax
The function tries to write a data frame to a DBF file.
\end{Description}
\begin{Usage}
\begin{verbatim}
write.dbf(dataframe, file, factor2char = TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{dataframe}] a data frame object.
\item[\code{file}] a file name to be written to.
\item[\code{factor2char}] logical, default \code{TRUE}, convert factor columns to
character: otherwise they are written as the internal integer codes.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Dots in column names are replaced by underlines in the DBF file, and
names are truncated to 11 characters.

Only vector columns of classes \code{"logical"}, \code{"numeric"},
\code{"integer"}, \code{"character"}, \code{"factor"} and
\code{"Date"} can be written.  Other columns should be converted to
one of these.

Maximum precision (number of digits including minus sign and decimal
sign) for numeric is 19 - scale (digits after the decimal sign) which is
calculated internally based on the number of digits before the decimal
sign.
\end{Details}
\begin{Value}
Invisible \code{NULL}.
\end{Value}
\begin{Note}\relax
Other applications have varying abilities to read the data types used
here.  Microsoft Access read \code{"numeric"}, \code{"integer"},
\code{"character"} and \code{"Date"} fields, including recognizing
missing values, but not \code{"logical"} (read as \code{0,-1}).
Microsoft Excel understood all possible types but did not interpret missing
values in character fields correctly (showing them as character nuls).
\end{Note}
\begin{Author}\relax
Nicholas J. Lewin-Koh, modified by Roger Bivand and Brian Ripley;
shapelib by Frank Warmerdam.
\end{Author}
\begin{References}\relax
\url{http://shapelib.maptools.org/}
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{read.dbf}{read.dbf}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
str(warpbreaks)
try1 <- paste(tempfile(), ".dbf", sep = "")
write.dbf(warpbreaks, try1, factor2char = FALSE)
in1 <- read.dbf(try1)
str(in1)
try2 <- paste(tempfile(), ".dbf", sep = "")
write.dbf(warpbreaks, try2, factor2char = TRUE)
in2 <- read.dbf(try2)
str(in2)
unlink(c(try1, try2))
\end{ExampleCode}
\end{Examples}

