R closes unexpectedly with write.dbf()
On Thu, 21 Apr 2005, Robin Schroeder wrote:
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.
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.
I am running R 2.0.0 on windows xp. Any ideas? Thanks in advance, Robin Schroeder
Robin Tori Schroeder (formerly Schoeninger) International Institute for Sustainability P.O. Box 873211 Arizona State University Tempe, Arizona 85287-3211 Phone: (480) 727-7290
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no