dbf.write {maptools} | R Documentation |
The function tries to write a data frame to a DBF file.
dbf.write(dataframe, filename, factor2char=TRUE)
dataframe |
a data frame object |
filename |
a file name to be written to |
factor2char |
logical, default TRUE, convert factor columns to character |
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.
no return value.
From maptools 0.4-7, this function is placed in the user-visible namespace on a trial basis, and reports of any malfunction should be sent to the package maintainer, Roger Bivand Roger.Bivand@nhh.no. It is likely that this function and its arguments will be changed.
Nicholas J. Lewin-Koh, modified by Roger Bivand; shapelib by Frank Warmerdam
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)