Hello,
This is my first time posting in here and I am beyond new to R studio. I am trying to import a file but the error given is
Error in read.dbf("courseprojectdata.dbf") :
could not find function "read.dbf"
What am I doing wrong here?
thanks
Hello,
This is my first time posting in here and I am beyond new to R studio. I am trying to import a file but the error given is
Error in read.dbf("courseprojectdata.dbf") :
could not find function "read.dbf"
What am I doing wrong here?
thanks
Hi @megamom and welcome to the RStudio community
The read.dbf()
function is a function, which is only available in a package called foreign
. So, you first need to install that package (which you do only once), then you need to open it. That's when you will be able to access the function. Your code should look like this:
install.packages("foreign") # This will install the package and you need to run it only once
library(foreign) # Open the package once it is installed
mydata <- read.dbf("courseprojectdata.dbf") # this will import your data and will store it in a variable called mydata
Glad to hear it worked
I want to add a bit more about understanding packages. The line install.packages("foreign")
installs the package from the internet to your computer. You only need to do this for packages you use for the first time or after an update to R. It's not best practice to save this line in your code. Sometimes I have it in there but commented out but never left in a program so it just runs every time.
The line library(foreign)
loads the package from your computer to your R session so you need to include that every time you need to use functions from that package.
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.