Beispiel #1
0
 def __init__(self, *args, **kwargs):
     od = OrdDict()
     for item in args:
         od[None] = conversion.py2ro(item)
     for k, v in kwargs.iteritems():
         od[k] = conversion.py2ro(v)
     res = self._constructor.rcall(od.items(), robjects.globalenv)
     self.__sexp__ = res.__sexp__
Beispiel #2
0
 def assign(self, index, value):
     """ Assign a given value to a given index position in the vector """
     if not (isinstance(index, rlc.TaggedList) | \
                 isinstance(index, rlc.ArgsDict)):
         args = rlc.TaggedList([conversion.py2ro(index), ])
     else:
         for i in xrange(len(index)):
             index[i] = conversion.py2ro(index[i])
         args = index
     args.append(conversion.py2ro(value))
     args.insert(0, self)
     res = r["[<-"].rcall(args.items())
     res = conversion.ri2py(res)
     return res
Beispiel #3
0
    def subset(self, *args, **kwargs):
        """ Subset the "R-way.", using R's "[" function. 
           In a nutshell, R indexing differs from Python's on:

           - indexing can be done with integers or strings (that are 'names')

           - an index equal to TRUE will mean everything selected (because of the recycling rule)

           - integer indexing starts at one

           - negative integer indexing means exclusion of the given integers

           - an index is itself a vector of elements to select
        """
        
        args = [conversion.py2ro(x) for x in args]
        for k, v in kwargs.itervalues():
            args[k] = conversion.py2ro(v)
        
        res = r["["](*([self, ] + [x for x in args]), **kwargs)
        return res
Beispiel #4
0
    def new(cls,
            geom, geom_params,
            stat, stat_params,
            data,
            aesthetics,
            position,
            params):

        args = [conversion.py2ro(x) for x in (geom, geom_params,
                                              stat, stat_params,
                                              data,
                                              aesthetics,
                                              position,
                                              params)]

        res = cls(cls.contructor)(*args)
        return res
Beispiel #5
0
 def __setitem__(self, item, value):
     robj = conversion.py2ro(value)
     super(REnvironment, self).__setitem__(item, robj)
Beispiel #6
0
 def setdim(self, value):
     value = conversion.py2ro(value)
     res = r["dim<-"](self, value)
         #FIXME: not properly done
     raise(Exception("Not yet implemented"))