3

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?

  • I wonder if this is an issue with the plugin not supporting the new SIP API? The fix below only works on the stable version. – SaultDon Jun 20 '13 at 4:41
5

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

  • Thanks Don. When I run a script, I don't get the message you show. I get: "Missing dependency.This algorithm cannot be run :-( It seems that R is not correctly installed in your system. Please install it before running R Scripts." I am new at R, but I think managed to install rgdal and SP from the R GUI directly (not sure how via command line), and they appear to have worked. Opening QGIS again results in the same error as above. – Darren Cope Jun 20 '13 at 11:51
  • If the path to the R Folder is correct, and it still gives a problem, can you see if it's an issue with the architecture type of R (ie, 32bit vs 64bit?). Maybe try installing R with both the 32 and 64bit. SEXTANTE in QGIS might need a specific arch of R to run scripts. I know QGIS from OSGEO4W is 32bit. – SaultDon Jun 20 '13 at 15:32
  • I installed both 32 and 64 bit versions of R, and tried with the "Use 64 bit version" option box checked and unchecked, in the Sextante options, with no luck. – Darren Cope Jun 20 '13 at 15:52
  • One last thing I can think of before I get home to test it on a fresh VM is, in your Users folder, delete (or just rename) the sextante folder in the .qgis folder? That sextante folder can hold some conflicting settings or history. – SaultDon Jun 20 '13 at 23:10
  • Interesting; I have both a .qgis and a .qgis2 folder in my users directory. I renamed the sextante folder in .qgis, and nothing changed. I renamed the one in .qgis2, and a new setante folder was created, leading me to believe it is using .qgis2 - however, this still did not work after resetting the R Folder path in the options menu. Perhaps there's something about the qgis2 folder that is causing issues? Are these folders auto-created? Can I just delete both and start fresh? – Darren Cope Jun 21 '13 at 12:18
0

I have experienced a similar issue, and slightly differently under Ubuntu and under Windows.

On Ubuntu, Sextante found R but couldn't run any of the scripts despite the relevant libraries having been installed from the R console. It looks like Sextante wants to use a different library store to the default which happens to be in a protected system folder, so my workaround was to run QGIS as a superuser once to load each script in turn so it could install the libraries it wanted, where it wanted. Afterwards it was happy to load as a normal user until the next time I need a library it doesn't see.

On Windows, I also had an issue where it wouldn't reliably set the R folder. There was nothing wrong with my R installation, it loaded fine in any manner except from within Sextante. When I looked in the Sextante folder in .qgis, the conf file was pointing to a different location than was set in the options menu. Manually correcting this seemed to solve the problem.

I then needed to run QGIS as an admin, as with Ubuntu, to ensure it loaded the libraries it needed, where it needed - again this is only needed when you first need a new library Sextante isn't aware of.

Essentially, for whatever reason, Sextante's R set-up seems to be broken from a users perspective but at least there's a workaround.

(The same works for the "Processing" plugin nuder QGIS 2.x)

0

The issue is that R is installed under Program Files by default, which is write-protected. Install R into another folder such as C:\R\R-3.1.3 and the problem goes away when you set it as the R path in QGIS. The solution is described here: http://wiki.awf.forst.uni-goettingen.de/wiki/index.php/R_installation

This worked running QGIS 2.8.1 Wien on Windows 7 64-bit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.