QGIS Sextante – Setting ‘R Folder’ Path

qgisrsextante

I have installed R via the R-Project website. I have QGIS installed via OSGEO4W (currently 1.9.0 Master), and have Sextante plugin installed and working with GRASS and SAGA providers. I am now trying to get R to run, but with no luck. I initially installed R to Program Files, but found mention that perhaps the space in the file path was an issue, so I have re-installed to C:\R\R-3.0.1\

What paths do I need to enter the "R Folder" and "RScripts Folder" configuration area in Sextante? Or am I missing something?

Best Answer

EDIT: I'm going to see if this bug is related (http://hub.qgis.org/issues/8012).

UPDATE: Looks like there are some issues with R in the sextante plugin for both qgis and qgis-dev. I'll file some bug reports if they haven't been already. But the two issues with R in sextante are:

1) In qgis (stable) SEXTANTE doesn't seem to use the rlib path in the Users .qgis folder. Instead it relies on the default R library path in C:/. The plugin will still download and install the missing libraries into the qgis sextante plugin folder but won't actually use them. You have to install them from R manually - eg, install.packages("rgdal")

2) In qgis-dev (unstable) SEXTANTE doesn't launch any R scripts and gives a warning about missing dependencies and that R is not properly installed. This is the OPs problem.


  1. Install R like you have.
  2. Install and open QGIS, install the SEXTANTE plugin like you've also done
  3. Select the pull-down menu Analysis > SEXTANTE options and configuration
  4. Expand R scripts in the Sextante options window and set the R folder to your R directory (ie, C:\Program Files\R\R-3.0.1). You don't have to worry about R Scripts folder unless you have a different place where you store your RScripts.

Now the funny part, possibly a bug...

Try to run one of the R scripts in the SEXTANTE Toolbox, like Create regular sampling grid.

This fails, with the helpful error:

options("repos"="http://cran.us.r-project.org") 
tryCatch(find.package("rgdal"), error=function(e) install.packages("rgdal", lib="C:/Users/userman/.qgis//sextante/rlibs")) 
trying URL 'http://cran.us.r-project.org/bin/windows/contrib/3.0/rgdal_0.8-9.zip' 
Content type 'application/zip' length 11911822 bytes (11.4 Mb) 
opened URL 
downloaded 11.4 Mb 

package 'rgdal' successfully unpacked and MD5 sums checked 

The downloaded binary packages are in 
C:\Users\userman\AppData\Local\Temp\RtmpyEEQJa\downloaded_packages 
library("rgdal") 
Error in library("rgdal") : there is no package called 'rgdal' 
Execution halted 
Converting outputs
Loading resulting layers
Algorithm Create regular sampling grid finished

The plugin is downloading and installing the libraries to it's custom rlib path, but when it goes to run the actual tool/script, it's not searching that path - but instead the default system rlib path.

The FIX - Install the needed library from the R interface (ie, launch R directly). Then go back to QGIS and launch the scripts.

Now they run! Output of random sample grid:

Result of R Random Sample Grid script in SEXTANTE Toolbox for QGIS

Related Question