Feature request #12250

Ability to load R packages and easily execute custom R scripts without Python code

Added by Irucka Embry over 9 years ago. Updated over 7 years ago.

Status:Closed
Priority:Normal
Assignee:Victor Olaya
Category:Processing/Core
Pull Request or Patch supplied:No Resolution:fixed/implemented
Easy fix?:No Copied to github as #:20435

Description

In an answer to a question posted (http://gis.stackexchange.com/questions/75320/is-it-possible-to-create-and-run-custom-r-scripts-in-qgis-2-0?s=5|1.4552) at the GIS Stack Exchange, Guillermo Olmedo posted a link to his Python scripts with R code (saved as .rsx files).

Instead of .rxs files, I would like the ability to load custom R scripts as .R files without any Python code. I would like the ability to load any installed R package (or download R packages if not already installed and then load) into QGIS when executing a custom R script as well.

Thank you.

simple_R_script_fail.txt Magnifier - Log of simple R script processed by SEXTANTE (3.09 KB) Irucka Embry, 2015-05-08 06:49 PM

simple.rsx - simple R script (598 Bytes) Irucka Embry, 2015-05-08 06:49 PM

History

#1 Updated by Irucka Embry over 9 years ago

Hi, would it be possible to use rpy2 (http://rpy.sourceforge.net/) to have the interface to R?

I know that SageMath (http://www.sagemath.org/) includes a working environment for R and it's also Python-based.

Thank you.

#2 Updated by Giovanni Manghi over 9 years ago

Irucka Embry wrote:

Hi, would it be possible to use rpy2 (http://rpy.sourceforge.net/) to have the interface to R?

I know that SageMath (http://www.sagemath.org/) includes a working environment for R and it's also Python-based.

Thank you.

We had plugins in the past that worked on top of rpy(2) and they were all a bit painful to use and maintain, and if fact they stopped to be maintained. R is now integrated in QGIS via the Processing toolbox, there you can run any R script.

#3 Updated by Irucka Embry over 9 years ago

Thank you for your note about the ability to run any R scripts from QGIS. I originally posted this feature request because I still have yet to be able to use any of my own R scripts in the SEXTANTE Processing Toolbox. I am using QGIS 2.8.1 on Trisquel 7.0, which is based off of Ubuntu Trusty. I have also tried in previous versions of QGIS with no success. I have attached the simple R script and the log output from the SEXTANTE Processing Toolbox. I attempted to run the script in the custom script window of the Toolbox.

Since rpy(2) was a horrible experience maybe using pyRServe could serve as a better interface to R and to the existing libraries installed on the computer. I performed some more research today on connecting Python/QGIS and R and the following 3 links are possibilities for making the R accessibility better:

1) https://pythonhosted.org/pyRserve/index.html
pyRServe is a library for connecting Python to an R process running under Rserve. Through such a connection variables can be get and set in R from Python, and also R-functions can be called remotely.

2) http://www.rforge.net/Rserve/
Rserve

3) http://stackoverflow.com/questions/11716923/python-interface-for-r-programming-language
Python interface for R Programming Language - Stack Overflow

Thank you.

#4 Updated by Alexander Bruy almost 9 years ago

  • Resolution set to fixed/implemented
  • Tag deleted (R, statistics, scripts, packages)
  • Status changed from Open to Closed

If I'm not wrong, Processing allow you to add scripts in pure R. Reopen if necessary

#5 Updated by Irucka Embry almost 9 years ago

Processing does not allow scripts to be created in pure R. Here is an example from the scatterplot regressione script (only the last 2 lines are R commands):

##My scripts=group
##showplots
##Layer=vector
##X=Field Layer
##Y=Field Layer
##Title=string
plot(LayerX, LayerY, xlab=X, ylab=Y, main=Title)+
abline(lm(LayerY~LayerX))

Thank you.

Irucka Embry

#6 Updated by Giovanni Manghi over 7 years ago

  • Easy fix? set to No

#7 Updated by Giovanni Manghi over 7 years ago

Some providers are being removed from QGIS/Processing (will be available as plugin) and so are their categories in the bug tracker. To not leave them orphaned of a category they are being reassigned to processing/core.

#8 Updated by Giovanni Manghi over 7 years ago

  • Category changed from 124 to Processing/Core

Also available in: Atom PDF