1

I am on this site from some days for a work in R I am doing (on R-Studio), but I could not find the answer to my problem yet (it's the 3rd day I use R). The error is what follows:

Error in readOGR(getwd(), "myfile") : could not find function "readOGR"

I am following a tutorial that should guide me through this work, and it gives me all the installation packages I need. I already installed what follows (directly from my console):

install.packages(c("rgdal","rgeos","BAMMtools","RColorBrewer"))

Once installed, I wrote:

i=read.csv("myfile.csv", header=TRUE, sep=";")

and it worked perfectly, but when I got to

c=readOGR(getwd(),"myotherfile")

it didn't work, and I tried really hard!

I already tried the following codes trying to load the data:

readOGR(dsn=path.expand("~/way/to/my/file/myfile"),layer="myfile")

(my data is all saved in the same working directory file), I tried:

library(raster)
c = shapefile("~/way/to/my/file/my file.shp")

And it didn't work... At this point (as I do absolutely know nothing in R) I do really have to look for help elsewhere!

Anyways the tutorial should really already give me all info and data, but I can't understand why this one thing doesn't work...

MrFlick i THINK YOU INTENDED THIS:

As someone made me see a similar question was already asked, the answer to that question was what follows, BUT:

Did you write the name of your function correctly? Names are case sensitive. YES Did you install the package that contains the function? install.packages("thePackage") (this only needs to be done once) YES Did you attach that package to the workspace ? require(thePackage) or library(thePackage) (this should be done every time you start a new R session) YES

I will appreciate any try to help :) thank you very much!

Bruno

Bruno
  • 11
  • 2
  • 2
    After you install the packages you need to load them. Run `library(rgdal)` – MrFlick May 04 '17 at 20:47
  • Show your `sessionInfo()` at the time of the error to verify that `rgdal` has been loaded. – MrFlick May 04 '17 at 21:59
  • other attached packages: '[1] rgdal_1.2-7 sp_1.2-4 rgeos_0.3-23' – Bruno May 05 '17 at 15:16
  • And you're sure `Error in readOGR(getwd(), "myfile") : could not find function "readOGR"` is the exact error message you are getting? That really dosen't seem possible if `rgdal_1.2-7` is loaded. There has to be something you are leaving out. – MrFlick May 05 '17 at 15:30

0 Answers0