Feature request #12250
Ability to load R packages and easily execute custom R scripts without Python code
|Pull Request or Patch supplied:||No||Resolution:||fixed/implemented|
|Easy fix?:||No||Copied to github as #:||20435|
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.
#2 Updated by Giovanni Manghi over 5 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.
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 5 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:
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.
Python interface for R Programming Language - Stack Overflow
#5 Updated by Irucka Embry almost 5 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):