[R] Unexpected result of read.dbf
Susumu Tanimura
stanimura-ngs at umin.ac.jp
Thu Aug 18 08:04:46 CEST 2005
Hi there,
Unexpected result is given with read.dbf from foreign 0.8-9, which is
reproducible in R 2.1.1 with the following sample data:
---- test.dbf ----
KEYCODE,N,19,0
422010010
42201002101
42201002102
42201002103
42201002104
422010060
422010071
422010072
42201008001
42201008002
422010100
42201011001
42201011002
422010130
422010140
42201015001
42201015002
42201015003
422010180
422010190
In the example, the name of column is "KEYCODE" with numeric type, 19
digits, and no decimal.
The data was saved as CSV format for confirmation.
> dbf.test <- read.dbf("test.dbf")
> dbf.test[1:20,]
[1] 422010010 NA NA NA NA 422010060 422010071
[8] 422010072 NA NA 422010100 NA NA 422010130
[15] 422010140 NA NA NA 422010180 422010190
> csv.test <- read.csv("test.csv")
> csv.test[1:20,]
[1] 422010010 42201002101 42201002102 42201002103 42201002104 422010060
[7] 422010071 422010072 42201008001 42201008002 422010100 42201011001
[13] 42201011002 422010130 422010140 42201015001 42201015002 42201015003
[19] 422010180 422010190
I wonder why I get NA from test.dbf. I have this kind of trouble when
handling ESRI Shape files with maptools. There is no choice to use
read.csv instead of read.dbf at executing read.shape.
--
Susumu Tanimura
More information about the R-help
mailing list