[GIS] Unable to run R in QGIS 2.6 – rgdal unavailable for R 3.1

installationmacqgisrrgdal

I'm attempting to use R within QGIS2.6 on OSX Mavericks but cannot get R to run because rgdal is not available as binary for R3.1.2 (see QGIS log output from R execution console below).

I have installed rgdal on my system R installation using an alternative to install.package but QGIS doesn't seem to be seeing this. Does QGIS use an different R/rgdal location to my main system versions?

R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)

…some packages downloaded here…

The downloaded binary packages are in
/var/folders/q4/r2k75kq956l54c4xtcxkscl40000gn/T//RtmpOSE4WR/downloaded_packages
tryCatch(find.package("spatstat"), error=function(e) install.packages("spatstat", dependencies=TRUE))
[1] "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/spatstat"
tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", dependencies=TRUE))
package 'rgdal' is available as a source package but not as a binary
Warning message:
package 'rgdal' is not available (for R version 3.1.2)
tryCatch(find.package("raster"), error=function(e) install.packages("raster", dependencies=TRUE))
[1] "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/raster"
library("raster")
Loading required package: sp
library("rgdal")
Error in library("rgdal") : there is no package called 'rgdal'
Execution halted

added whole error log output January 7, 2015 23:07:23
R execution console output

R version 3.1.2 (2014-10-31) — "Pumpkin Helmet"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

options("repos"="http://cran.at.r-project.org/")
tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", dependencies=TRUE))

package 'rgdal' is available as a source package but not as a binary

Warning message:
package 'rgdal' is not available (for R version 3.1.2)
tryCatch(find.package("raster"), error=function(e) install.packages("raster", dependencies=TRUE))
[1] "/Library/Frameworks/R.framework/Versions/3.1/Resources/library/raster"
library("raster")
Loading required package: sp
library("rgdal")
Error in library("rgdal") : there is no package called 'rgdal'
Execution halted

Best Answer

Here, see if this works:

# This sets the correct dependencies on CRAN
setRepositories(ind = c(1,6))  

# Then install package as usual. 
install.packages('rgdal')
Related Question