Skip to content

R closes unexpectedly with write.dbf()

2 messages · Robin Schroeder, Roger Bivand

#
Dear R-list,

I am trying to do a relatively simple manipulation in R on a dbf file and then write the dbf file back out the file system. Here are the commands:

(load the foreign library package) 
union <- read.dbf("C:/ITRSampleData/fromGrass/union.dbf", as.is=FALSE) 
attach(union) 
union$wu_fract <- area_union*a_SUM/a_area_tor 
detach(union) 
write.dbf(union, "C://ITRSampleData/fromR/union_postR.dbf") 

after I run the last command, Windows tells me that R has encountered a problem and needs to shut down. It also asks if I want to report the problem to microsoft... R then shuts down completely. 

I have tried this with the factor2char=TRUE and FALSE, with the same result. 
I checked is.data.frame(union) and it is true.

An empty dbf file is created in the correct place, so I know R has access/permissions and my file path is correct.

I have used the write.dbf command in a number of other places and have never run into this problem. 

I am running R 2.0.0 on windows xp.

Any ideas?

Thanks in advance,
Robin Schroeder
#
On Thu, 21 Apr 2005, Robin Schroeder wrote:

            
Please state the version of the foreign library you are using, update
foreign to 0.8-7, and try again. There were two bugs in write.dbf() up to
0.8-5, one when a column of the data frame was all 0 and the other when a
column was all NA. Also please do summary(union$wu_fract) - I suspect it
is either all 0 or NA. 0.8-7 guards against both of these problems, which
are in code trying to work out the appropriate width of the output DBF
fields.