Are you using rpy2-2.1dev ? If so, there were issues and you will want a (very) fresh update of the code on the bitbucket repository.
L. Manuel A. Rivas wrote: > Thanks Laurent, > > Were you able to succesfully create the lm ? > > I get the following error with NO_CONVERSION: > > >>> rpy.r.lm(rpy.r("y ~ x"), data = rpy.r.data_frame(x=my_x, y=my_y)) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/home/radon00/rivas/lib/python/rpy2/rpy_classic.py", line 265, > in __call__ > return self.eval(self.parse(text=s)) > File "/home/radon00/rivas/lib/python/rpy2/rpy_classic.py", line 199, > in __call__ > a = a.getSexp() > AttributeError: 'Robj' object has no attribute 'getSexp' > > > thanks, > manuel > > On Aug 5, 2009, at 11:17 AM, Laurent Gautier wrote: > >> Manuel A. Rivas wrote: >>> Hello , I am trying to use the r.nls function from rpy2 in the same >>> fashion as rpy by importing rpy_classic. In R: the syntax y ~ x >>> would tell the lm function that y depends on x as its model. In >>> python using rpy I would use rpy's "evaluate a string" functionality. >>> i.e. >>>> >>> from rpy import r >>>> >>> my_x = [5.05, 6.75, 3.21, 2.66] >>>> >>> my_y = [1.65, 26.5, -5.93, 7.96] >>>> >>> print r.lm(r("y ~ x"), data = r.data_frame(x=my_x, >>>> y=my_y))['coefficients'] >>> as described in the man pages: However, if I do the same with rpy2 >>> >>> from rpy2.rpy_classic import r >>> >>> my_x = [5.05, 6.75, 3.21, 2.66] >>> >>> my_y = [1.65, 26.5, -5.93, 7.96] >>> >>> r.lm(r("y ~ x"), data = r.data_frame(x=my_x, y=my_y)) >>> I get the following error: Traceback (most recent call last): >>> File "<stdin>", line 1, in <module> >>> File "/home/radon00/rivas/lib/python/rpy2/rpy_classic.py", line 265, >>> in __call__ >>> return self.eval(self.parse(text=s)) >>> File "/home/radon00/rivas/lib/python/rpy2/rpy_classic.py", line 215, >>> in __call__ >>> res = rpy2py(res) >>> File "/home/radon00/rivas/lib/python/rpy2/rpy_classic.py", line 174, >>> in rpy2py >>> res = rpy2py_basic(obj) >>> File "/home/radon00/rivas/lib/python/rpy2/rpy_classic.py", line 160, >>> in rpy2py_basic >>> raise ValueError("Invalid type for 'obj'.") >>> ValueError: Invalid type for 'obj'. >>> any ideas how to do the same operation in rpy2 with rpy_classic? >> >> Try adding this to the beginning: >> >> import rpy2.rpy_classic as rpy >> rpy.set_default_mode(rpy.NO_CONVERSION) >> >> >> (rpy_classic is way behind the rest of rpy2 because of limited time on >> my end, and seemingly limited interest/contributions from users in >> having it improved to a full compatibility). >> >> >> >> L. >> >> >>> thanks, >>> Manuel Rivas >>> ------------------------------------------------------------------------ >>> ------------------------------------------------------------------------------ >>> >>> >>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >>> 30-Day trial. Simplify your report design, integration and deployment >>> - and focus on what you do best, core application coding. Discover >>> what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july >>> ------------------------------------------------------------------------ >>> _______________________________________________ >>> rpy-list mailing list >>> rpy-list@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/rpy-list >> > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list