richard mendes wrote:
> Hello Sean,
> The code that i was using was simply pasting the same code in python.
> r("i<-1")  # i should use the attach statement i think
> r("while (i <= length(groups) ) {")
> r("png(file=sprintf('MAplot%03d.png', i), width=600, height=600)")
> r("MAplot(rawAffyData, pairs=TRUE, plot.method='smoothScatter'
> which=groups[[i]])")
> r("dev.off()")
> r("i<-i+1 }")
> 
> But i expect that using rpy in such a way is completely wrong. I'm just
> testing what can be done by rpy

Options:

  * Try sticking all your string commands in one long string and running 
it all at once.

  >>> loop="i=0;while(i<10){i=i+1}"
  >>> r(loop)
  10.0

  * Write your loop in Python, and only call png and MAplot using Rpy. 
You'll learn how to pass variables between python and R too!

  >>> for i in range(len(r.groups)):
  ...   print i

will loop from 0 to length(groups)-1 (python starts indexes at 0)

  Then do:

  >>> r.assign("i",i+1)
   - this creates an R object with the value of the python 'i' + 1

  Then do your calls inside the loop. No need to increment the 'i' in R, 
your loop controller is now a python variable. You should end up with 
this (untested):

  for i in range(len(r.groups)):
   r.assign("i",i+1)
   r("png(file=sprintf('MAplot%03d.png', i), width=600, height=600)")
   r("MAplot(rawAffyData, pairs=TRUE, plot.method='smoothScatter' 
which=groups[[i]])")
   r("dev.off()")


> Currently they have rserve running on a server that connects several app's
> to R. The only problem is that i couldn't
> find a interface between python and rserve.

  I half-wrote this and then discovered Rpy. I have an alpha version if 
you want it, but trust me, you probably don't want it. It was at the 
'now this is a real mess, it needs rewriting from scratch' stage.

Barry

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to