From ben.bob at gmail.com  Mon Jan  9 17:36:37 2006
From: ben.bob at gmail.com (Bo Peng)
Date: Mon, 9 Jan 2006 10:36:37 -0600
Subject: [Rd] R plot display problem under windows when using python rpy
	module.
In-Reply-To: <43C28618.8060601@cimr.cam.ac.uk>
References: <6ea7b5430601090629u6c3a6ed4r41d096e61c2579e7@mail.gmail.com>
	<43C28618.8060601@cimr.cam.ac.uk>
Message-ID: <6ea7b5430601090836k76c9a331t4834bcd5a7a1bbca@mail.gmail.com>

> I was wondering
> what is the difference between rpy and RSPython.

The main difference is that rpy does one-way communication, is simpler
than RSPython, than is easier to use.

> So I have a question for you - why rpy instead of RSPython? Have you
> tried both, and can you give a comparison of pros and cons?

I am not an expert on RSPython. I tried RSPython and rpy and chose rpy
for the following reasons:

1. rpy is in active maintenance. As you can see from rpy webpage, rpy
supports all versions of R till 2.2.1, python 2.4 and provides binary
installers like rpy-0.4.6-R-2.0.0-to-2.2.1-xxxx.xxx . On the contrary,
a windows installer for RSPython is for R-1.4.0, python 2.2.0.

2. RSPython uses mainly its RS.call function. This is troublesome and
is the main reason why I use rpy. For example,

in RSPython:
  RS.call('rnorn', 10)
in rpy:
  r.rnorm(10)

RSPython does provide similar usage now (maybe after I became a rpy user) but
RSPython:
  from RS import R
  R.rnorm(10)   # works
  R.dev.off()     # does not work

Rpy solves this problem by (and the mechanism is clearly described in
the rpy manual):
  from rpy import *
  r.rnorm(10)
  r.dev_off()

rpy also provides
  r('''arbitrary R piece of code''')
which is immensely useful to run big trunk of R code.

rpy also claims that the performance of rpy is better but I have no
comparison data here.

>  there is nothing wrong with having a bias,
> but the goals listed imply that it might be "better" in those areas...
> which may or may not be true.

I agree.

> (To answer one question you might have, I was trying to invoke Python
> code from inside R and was doing it the opposite direction from you).

Exactly. We are doing different things so while you have to use
RSPython, I have a choice between RSPython and rpy. In my case, all
the real computations are done in C/C++, wrapped by Python. I could
have wrapped my C/C++ code in R but R is not good at wrapping C++
class hierarchy because of the different OOP mechanisms. When I need
the statistical analysis and plotting capacity of R, I use rpy.

As a matter of fact, since Python is a powerful programming language
than can handle string, text file etc better than R, I usually prepare
my data in python  and pass them to R using rpy.

Cheers,
Bo



[Rd] R plot display problem under windows when using python rpy module.
Bo Peng