On Mon, 2008-10-13 at 10:51 +0100, Peter wrote:
> Peter wrote:
> >> Does the rpy v1 style r.dev_off() still work in rpy v2?
> 
> Laurent replied:
> > Not directly. I have a sketchy attempt at making it possible (will be
> > there for the 2.0 release, still scheduled for November), but it will
> > not be the default.
> >
> >> Personally I
> >> much prefer this to r['dev.off']() for readability.
> >
> > This is indeed saving 4 keystrokes, but have the significant
> > disadvantage of being the likely source of a lot of problem to the
> > unaware user.
> 
> There is also the strong advantage of supporting r.dev_off() and
> similar for people wanting to port existing code from rpy1 to rpy2.
> If this supporting this kind of "name mangling" could be enabled at or
> just after the import lines, that could be very helpful.
> 

I hear you.
Although I see the strength of that possibility as very relative
(one can also always do:
dev_off = robjects.r['dev_off']
), there is something to your liking in beta1.

try:

import rpy2.robjects as ro
ro.r._dotter = True
ro.r.dev_off()


> [Have you written anything about converting existing rpy1 code to
> rpy2?  I should probably read it if you have...]

Few bullet points about the differences in general are in the current
doc at the moment. Not more than that.
There is also a module "rpy_classic" that is a rough emulation of rpy
built with rpy2.rinterface (the emulation is rough because of limited
time on my end - this is also a demo of how how could build an interface
to R without touching on C code).

> > What if there is a user-defined function called 'dev_off' in the R
> > search path ?
> >
> > To save you the effort of starting comments on conversion rules such as
> >  *  '.' -> '_'
> >  *  '_' -> '__',
> > I'll be bringing up that '___' in python cannot be disambiguated (can
> > be either '._' or '_.' in R).
> >
> > rpy2 will be trying to be 'safe by default'.
> 
> I believe that prior to R version 1.9, R didn't originally allow
> underscores in function names / arguments / variables, which would
> explain why rpy1 did the dot/underscore switching in the first place.

R allows pretty much anything in function names... and this for pretty
much as I remember.

Try this in R:
> a <- 123
> `I can't believe this !` <- 123
> `I can't believe this !`
[1] 123
> ls()
[1] "a"                      "I can't believe this !"

I should not have to insist further on the limitations of the
'get by attribute' option, and on the impossibility to make it work
on everything.


L.



> From the pry point of view, its annoying that R now allows both dots
> (peridods) and underscores :(
> 
> Peter


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to