Search This Blog

Sunday, August 9, 2015

Reading dbf files in R

In this post, we will see how to load dbf tables in R.

First item is to install the appropriate R library. In this case, it happens to be a library called foreign.

Run R in administrative mode so that library can be installed in the universal library

sudo R

> install.packages("foreign")


Quit R and re-enter R in non-administrative (non-sudo) mode

At, the R prompt, enter the following commands

 library(foreign)  
 fatal_yr <- read.dbf("~/Work/Transportation/NYC/data/shpfiles/fatality_yearly.dbf")  
 dim(fatal_yr)  



That's it, we have loaded the dbf file.



No comments: