RSPython
I’ve decided to revive my blog due to this beast:
RSPython – Python interface to the R system and vice-versa.
I guess it would be great to have the best of both worlds, but the documentation (or lack of it) really puts me off. Nonetheless, I still need to play with this beast if I were to proceed with my projects.
So here we go:
1. Getting it. One can obtain a copy of RSPython from the author’s webby @ http://www.omegahat.org/RSPython/index.html
At the time of writing, the latest version is 0.7-1
2. Installation
Before proceeding to installation, it’s best to have this in order first:
- Python (i’m using Python2.5)
- R (try r-base in synaptics)
As the web suggested, installation requires you to issue this command:
R CMD INSTALL -c RSPython_0.7-1.tar.gz
oh wait, you might need administrative privileges to install the modules: so, make it:
sudo R CMD INSTALL -c RSPython_0.7-1.tar.gz
R will do the remaining job. Note that the installer has been preprogrammed to use a specific version of gcc (gcc-4.2), which at that time I didn’t have, and gave me installation error.
Once it says done, scroll your way up to the point where it starts the installation. Do take note of the installation directory. (mine at /usr/local/lib/R/site-library/RSPython)
Modify your .bashrc file to update your $PYTHONPATH
Add these 2 folder in your path:
1. [installFolder]/libs
2. [installFolder]/Python
And while you’re at it, add $R_HOME to point to your R installation dir if you have not done so. (mine at /usr/lib/R)
That’s it. You’re done. Now that the easy part is complete, let’s get serious
3. Testing installation
FROM R:
get R up n running
buddie@buddie-dell:~$ R
load RSPython
> library(RSPython)
If everything is alright, you might get these warning, which I think is pretty safe to ignore.
Initialized R-Python interface package.
Warning messages:
1: 'Sys.putenv' is deprecated.
Use 'Sys.setenv' instead.
See help("Deprecated")
2: the Python callback manager has been registered implicitly using the defaults (referenceManager())! in: .PythonInit()
I did run into a little problem while loading the library due to an extra comma ‘,’ in RSPython script
dirSep <- ifelse(R.version$os == "Win32", ";", ":",)
remove that and it should be okay.
FROM Python
Run python
$python
import RSPython
>>> import RS
Initialized R-Python interface package.
That’s the furthest I’ve gone so far.
Filed under: work | Leave a Comment
Tags: python, R, RSPython, ubuntu
Search
-
You are currently browsing the work-play-life weblog archives.
No Responses Yet to “RSPython”