Installing gstat for R on a Mac

I got the following error when trying to use install.packages("gstat") today,

> install.packages("gstat")

   package ‘gstat’ is available as a source package but not as a binary

Warning in install.packages :
  package ‘gstat’ is not available (for R version 3.1.1)

So then I downloaded gstat, and got the following,

ERROR: dependencies ‘spacetime’, ‘FNN’ are not available for package ‘gstat’

Fine, I’ll install spacetime and FNN. FNN installed easily enough, but spacetime spat this out,

ERROR: dependencies ‘xts’, ‘intervals’, ‘rgeos’ are not available for package ‘spacetime’

So then I installed xts and intervals using install.packages() within RStudio, but rgeos required the command line again, but then I got this error:

~
❯ R CMD INSTALL Downloads/rgeos_0.3-8.tar.gz
...
ERROR: configuration failed for package ‘rgeos’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rgeos’

So then I used Google and found this StackOverflow question which suggested I install geos with homebrew. Since I don’t know any better, I made /usr/local/[lib|bin|include] writable so that I could link the stuff I had installed. (I need to learn how to use homebrew better.)

So then I installed rgeos, spacetime, and gstat with the command line (R CMD INSTALL ...) and I lived happily ever after.

5 thoughts on “Installing gstat for R on a Mac”

  1. Hey I have the same problem, but I try to install those packages within each of the directories you mention [lib|bin|include], but i got this error Error: ERROR: no packages specified, i don’t know if you install from downloads or if you get first the packages with wget and install using the line command (R CMD INSTALL… ), I appreciate any help, I don’t know how to use homebrew either

    Thank you so much (and sorry for my english)

    1. No, your English is fine. I always install from downloads as R CMD INSTALL ~/Downloads/package.tar.gz, and that usually does it. You can get homebrew from their site and run the install script by copy and pasting the line of code at the bottom of their page. Let me know if you keep having trouble.

  2. Hi! thanks for the answer! I already have homebrew, but when I try to install the package rgeos this happen:

    bin JannaColt$ R CMD INSTALL ~/Downloads/rgeos_0.3-8.tar
    * installing to library ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library’
    * installing source package ‘rgeos’ …
    ** package ‘rgeos’ successfully unpacked and MD5 sums checked
    configure: CC: clang
    configure: CXX: clang++
    configure: rgeos: 0.3-4
    checking for /usr/bin/svnversion… yes
    configure: svn revision: 460
    checking geos-config usability… ./configure: line 2056: geos-config: command not found
    no
    configure: error: geos-config not usable
    ERROR: configuration failed for package ‘rgeos’
    * removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rgeos’

    and then I can’t install spacetime either gstat i’ve been trying but nothing, maybe I could use the brew install function, but i’m not so sure how

    1. Okay, try running “brew install geos” from the command line, if it says a directory isn’t writable, then change the permissions on that directory with “sudo chmod a+rwx /path/to/directory”. Let me know how it goes.

  3. Suffering the same problem, kinda got to the same solution.
    For xts, FNN, intervals, i used within R

    install.packages(“package_name”, type = “source”)

    and when asked if I wanted to make my own user library I said yes.

    Then I downloaded geos (http://trac.osgeo.org/geos/)
    and then used info from this page:
    https://docs.djangoproject.com/en/1.7/ref/contrib/install/geolibs
    to install geos.

    (BTW: I am new to mac and have never done much programming)

    This enabled me to install rgeos, using the first command above in R. Which enabled me to install “spacetime”. And finally, gstat, again using the install.packages, with type=”source”.

    this is on MAC OS, Mavericks 10.9. with R version 3.1.2.

    What a hassle eh !

    I

Leave a Reply

Your email address will not be published. Required fields are marked *