[Rd] [RFC] running octave, python from within R

Soeren Sonnenburg r-ml at nn7.de
Sun Mar 8 21:48:11 CET 2009


Dear all,

a Shogun 0.7.1 is out and available at http://www.shogun-toolbox.org

which contains one new feature that might be of interest to
R users. The eierlegendewollmilchsau interface. In
case you don't know what this term stands for use google images :-)

It is one file that will interface shogun to octave,r,python,matlab. It
provides commands to run code in foreign languages:

Example:

library(elwms)

A=matrix(c(1.0,2,3, 4,5,6), nrow = 2, ncol=3)
B=matrix(c(1.0,1,1, 0,0,0), nrow = 2, ncol=3)
pythoncode=sprintf('import numpy\nresults=tuple([A+B])');
elwms('run_python', 'pythoncode', 'print "hi"')
C=elwms('run_python', 'A',A, 'B',B, 'pythoncode', pythoncode)
D=elwms('run_python', 'A',A+1, 'B',B*2, 'pythoncode', pythoncode)
pythoncode=sprintf('import numpy\nresults=(A, B, [ "bla1",
"bla2" ])\n');
X=elwms('run_python', 'A',A, 'B',B, 'pythoncode', pythoncode)
print(A)
print(B)
print(C)
print(D)
print(X)


This would pass around matrices A and B do some processing and return
results. So you could use your old octave/matlab scriptspassing around
strings cells, or whatever matrices/stringsor plot some nice figures via
matplotlib in python

See http://www.shogun-toolbox.org/doc/elwmsinterface.html .
Don't even try to run octave from python from octave etc nested.
Neither octave, R nor python-numpy nor libshogun supports this :-)

Soeren



More information about the R-devel mailing list