1

I'm looking to export a dataframe as a dbf file in R, and am using write.dbf but I get an error that says:

Error in write.dbf(mydata, "mydata.dbf") : could not find function "write.dbf"

I've tried several variations of the filename portion for write.dbf (i.e no quotations, no extension, with the path included) but the all say the function can't be found.

Why is this the case?

joat1
  • 53
  • 2
  • 6
  • write.dbf is not a standard function in base R. You need to load the package library(foreign) maybe? – jasbner Oct 31 '18 at 20:09
  • 2
    Possible duplicate of [Error: could not find function ... in R](https://stackoverflow.com/questions/7027288/error-could-not-find-function-in-r) – pogibas Oct 31 '18 at 20:10
  • @jasbner was correct. I wasn't able to find what package write.dbf belonged to so thought it was a standard function. Thanks! – joat1 Oct 31 '18 at 20:29

2 Answers2

1

Try this:

install.packages("foreign")
library(foreign)
write.dbf(mydata, "mydata.dbf")
0

As commented, you should first load the package containing this function. if you don't remember which package the function is from, you might retrieve it using ??write.dbf

gaut
  • 5,771
  • 1
  • 14
  • 45