Re: [Rpy] how to pass a python object to R

2009-01-14 Thread Oliver Tomic
Hi Simone, maybe this helps: [code START] >>> import numpy >>> a = [[1,2,3],[4,5,6]] >>> aa = numpy.array(a) >>> aa array([[1, 2, 3], [4, 5, 6]]) >>> import rpy2.robjects as ro >>> import rpy2.robjects.numpy2ri >>> aR = ro.conversion.py2ri(aa) >>> aR >>> print aR [,1] [,2] [,

Re: [Rpy] loading an Rda file via rpy2 under mod_python

2009-01-14 Thread Rajarshi Guha
On Wed, Jan 14, 2009 at 10:26 AM, Laurent Gautier wrote: > > Your output from > r_listdir = robjects.r('''file.info(dir("/where/the/file/is"))''') > > is an empty directory. (?!) Try going up the directory structure and see if > any directory can be listed. Indeed, looking at some top level dirs

Re: [Rpy] how to pass a python object to R

2009-01-14 Thread Laurent Gautier
Simone Gabbriellini wrote: > I would like to know if there is something like r.assign('ROBJECT', > PYTHONOBJECT) in rpy2... http://rpy.sourceforge.net/rpy2/doc/html/robjects.html?highlight=assign#environments Or "assign" as you write above: r.assign("foo", 123) > I don't want to use R function

Re: [Rpy] how to pass a python object to R

2009-01-14 Thread Simone Gabbriellini
I would like to know if there is something like r.assign('ROBJECT', PYTHONOBJECT) in rpy2... I don't want to use R function to evaluate an object IN Python, I want to assign a matrix made in python to an R object... simone 2009/1/14 Simone Gabbriellini : > [so sorry but I just answer your mail..

Re: [Rpy] rpy2 compile on windows

2009-01-14 Thread Laurent Gautier
That's a bug in distutils on Windows. See http://www.mail-archive.com/rpy-list@lists.sourceforge.net/msg01365.html James Yoo wrote: > hello again, > > I've gotten really close to compiling R-2.8.1 and rpy2 on windows > (non-trivial if you don't have admin rights) > > hoping someone on this l

Re: [Rpy] how to pass a python object to R

2009-01-14 Thread Laurent Gautier
Simone Gabbriellini wrote: > yes, like that... > > but simply importing: > > Import rpy2.robjects.numpy2ri > > when I do: > > g1adj = numpy.array(g1adj) > > robjects.r('QAPset[1,,]<-g1adj') R has no way to know your Python variable called "gladj" unless you indicate it. print(robjects.r('ls

[Rpy] rpy2 compile on windows

2009-01-14 Thread James Yoo
hello again, I've gotten really close to compiling R-2.8.1 and rpy2 on windows (non-trivial if you don't have admin rights) hoping someone on this list may be able to recognize something here (besides my incompetence)... python setup.py build compiler=mingw running build running build_py runnin

[Rpy] how to pass a python object to R

2009-01-14 Thread Simone Gabbriellini
yes, like that... but simply importing: Import rpy2.robjects.numpy2ri when I do: g1adj = numpy.array(g1adj) robjects.r('QAPset[1,,]<-g1adj') it says: Error in eval(expr, envir, enclos) : object "g1adj" not found... while in the docs it says that: "That import alone is sufficient to switch an

Re: [Rpy] how to pass a python object to R

2009-01-14 Thread Laurent Gautier
Something like this http://rpy.sourceforge.net/rpy2/doc/html/numpy.html?highlight=numpy ? Simone Gabbriellini wrote: > dear List, > > is it possible to pass a matrix I've built in python to R via rpy2? > > I'm sure I'm blind, but I cannot find example about how to pass object > from python to

[Rpy] how to pass a python object to R

2009-01-14 Thread Simone Gabbriellini
dear List, is it possible to pass a matrix I've built in python to R via rpy2? I'm sure I'm blind, but I cannot find example about how to pass object from python to r, while I see how to pass object from r to python... best regards, Simone Gabbriellini --

Re: [Rpy] loading an Rda file via rpy2 under mod_python

2009-01-14 Thread Laurent Gautier
Rajarshi Guha wrote: > > > On Wed, Jan 14, 2009 at 8:33 AM, Laurent Gautier > wrote: > > Well, it does not crash (segfault, only rumbles remaining), > it just throws an exception about being unable to open the > connection. ;-) > > > Did you try to o

Re: [Rpy] loading an Rda file via rpy2 under mod_python

2009-01-14 Thread Volkan Kepoglu
i think rinterp("""load('test-model.Rda')""") should be like this: rinter("""load('test-model.Rdata')""") worked in win. On 1/14/09, Rajarshi Guha wrote: > Hi, I'm using rpy2 (2.0.1) in a mod_python script. Various rpy2 methods work > fine but when I try to call R's "load" command I get RRunT

Re: [Rpy] loading an Rda file via rpy2 under mod_python

2009-01-14 Thread Rajarshi Guha
On Wed, Jan 14, 2009 at 8:33 AM, Laurent Gautier wrote: > Well, it does not crash (segfault, only rumbles remaining), > it just throws an exception about being unable to open the connection. ;-) > > > Did you try to output to you webpage the outcome of: > > print(robjects.r('''file.info(dir("/whe

Re: [Rpy] loading an Rda file via rpy2 under mod_python

2009-01-14 Thread Laurent Gautier
Well, it does not crash (segfault, only rumbles remaining), it just throws an exception about being unable to open the connection. ;-) Did you try to output to you webpage the outcome of: print(robjects.r('''file.info(dir("/where/the/file/is"))''')) ? Rajarshi Guha wrote: > > > On Wed, Ja

Re: [Rpy] loading an Rda file via rpy2 under mod_python

2009-01-14 Thread Rajarshi Guha
On Wed, Jan 14, 2009 at 2:50 AM, Laurent Gautier wrote: > Wouldn't the working dir in which the process is running matter ? > > Using an absolute path might be indicated. Yes, I had thought of that. Interesting when I try and the read the using Python data = open('/ful/path/test-data.Rda').rea