Search code examples
rimportdbf

import .dbf into RStudio: failed on DBF filefseek (-2147207979)


I'm trying to import .dbf file into RStudio.

This file is the attribute table of a shapefile that I exported as .dbf. You can find the .dbf file in this link

I tried importing it as below

library(foreign)
df <- read.dbf("5layers1.dbf")

I got errors (below) and RStudio crashed so I couldn't get sessionInfo(). enter image description here

Any suggestions how to import this large .dbf file into RStudio will be highly appreciated.


Solution

  • I suggest to save it as a csv-file (I did this with LibreOffice in one or two hours and use ; as a separator). After you can import it to R like this:

    dat <- readLines("5layers1.csv")
    
    li <- strsplit(dat, ";")
    num <- as.numeric(unlist(lapply(li, `[[`, 100)))
    
    boxplot(num, main=unlist(strsplit(dat[1], ";"))[100])
    mtext(side=3, text=paste("n = ", length(num), sep=""))
    

    Its really a big file! You will have a lot of fun with this! I'm not sure if R is the tool for this job. I use a Tinkpad T430 with 8GB Ram and it need 2min for run this five lines to make this boxplot, which present one of the 179 attributes of your dbf-file:

    enter image description here