The DBF format is documented but not much adhered to. There is is no guarantee this will read all DBF files.
read.dbf(file, as.is = FALSE)
make.names(unique=TRUE)
.There is an attribute "data_type"
giving the single-character
dBase types for each field.
read.dbf
is based on C code from
http://shapelib.maptools.org/ which implements the
XBASE specification. It can convert fields of type
"L"
(logical), "N"
and "F"
(numeric and float)
and "D"
(dates): all other field types are read as-is as
character vectors. A numeric field is read as an R integer vector if
it is encoded to have no decimals, otherwise as a numeric vector. However,
if the numbers are too large to fit into an integer vector, it is
changed to numeric. Note that is possible to read integers that cannot be
represented exactly even as doubles: this sometimes occurs if IDs are
incorrectly coded as numeric.
write.dbf
x <- read.dbf(system.file("files/sids.dbf", package="foreign")[1])
str(x)
summary(x)
Run the code above in your browser using DataCamp Workspace