maptools (version 0.4-7)

dbf.write: Write a DBF file

Description

The function tries to write a data frame to a DBF file.

Usage

dbf.write(dataframe, filename, factor2char=TRUE)

Arguments

dataframe
a data frame object
filename
a file name to be written to
factor2char
logical, default TRUE, convert factor columns to character

Value

  • no return value.

Details

The function calls code from shapelib to write a DBF format. At present, NAs will cause an error and no file will be written. If factors should be represented as character fields, the data frame must either be pre-processed to convert those colums using I(as.character()), or the factor2char argument set to TRUE. In addition logical columns are converted to integer; maximum precision (number of digits including minus sign and decimal sign) for numeric is 19 - scale (digits after the decimal sign) is calculated internally based on the number og digits before the decimal sign.

References

http://shapelib.maptools.org/

See Also

dbf.read

Examples

Run this code
data(warpbreaks)
str(warpbreaks)
try1 <- paste(tempfile(), ".dbf", sep="")
dbf.write(warpbreaks, try1, factor2char=FALSE)
in1 <- dbf.read(try1)
str(in1)
try2 <- paste(tempfile(), ".dbf", sep="")
dbf.write(warpbreaks, try2, factor2char=TRUE)
in2 <- dbf.read(try2)
str(in2)

Run the code above in your browser using DataCamp Workspace