Next: , Previous: Calling R objects, Up: Robj type


3.2.2 Methods of Robj type

An object of type Robj has three methods:

as_py([mode])
This method forces the conversion of a Robj object to a classical Python object, whenever possible. If it is not possible, the same object is returned. The optional parameter is the mode from which to apply the conversion, see Modes. The default value for this parameter is the global mode (see R to Python).
autoconvert([mode])
local_mode([mode])
This method sets the local conversion mode for each object, which is used when the default mode is set to ‘NO_DEFAULT’, (see Python to R). When no argument is passed to this method, it displays the current local conversion mode of the object. (The two names are synonyms for compatibility with version 0.1.)
lcall([argument list])
This method calls the R object (if callable) using the parameters provided as a single list containing a 2 element (name, value) tuple for each arguments. Unnamed arguments may have None or ” as the name element.

For example:

     >>> r.seq.local_mode(NO_CONVERSION)
     >>> a = r.seq(3, 5)
     >>> a
     <Robj object at 0x814c2e8>
     >>> a.as_py()
     [3, 4, 5]
     >>> set_default_mode(NO_CONVERSION)
     >>> r.print_(r.c.lcall( (('',0),('a',1),('b',2),('c',3)) ) )
       a c b
     0 1 3 2
     <Robj object at 0xbc89d0>
     >>> set_default_mode(BASIC_CONVERSION)