Read a DBF File
The function reads a DBF file into a data frame, converting character fields to factors, and trying to respect NULL fields.
read.dbf(file, as.is = FALSE)
- name of input file
- should character vectors not be converted to factors?
DBF is the extension used for files written for the
read.dbf is based on C code from
"F" (numeric and float)
"D" (dates): all other field types are read as-is as
character vectors. A numeric field is read as an Rinteger 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.
- A data frame of data from the DBF file; note that the field names are
adjusted to use in R using
There is an attribute
"data_type"giving the single-character dBase types for each field.
The Borland file specification via
x <- read.dbf(system.file("files/sids.dbf", package="foreign")) str(x) summary(x)