Hi Michael, The trick here is that r['...'] expects the ... to be an object name, rather than a statement to be executed. The brackets following the name 'r' is shorthand for 'obtain the object named ... from r', which can also be expressed as, r.get('...')
RPy provides a similar syntax for executing arbitrary r code: r('...'] This is shorthand for 'execute r as a function on the following code snippet', or r.eval(r.parse('...')) So, either of the following expressions will accomplish the same thing: r['pwr.p.test'](h=0.2,power=0.95,sig_level=0.05) # get the R object named 'pwr.p.test' and call it as a function or r('pwr.p.test(h=0.2,power=0.95,sig.level=0.05)') # execute this R code. -Greg On Jun 19, 2007, at 11:32AM , Michael Grollman wrote: > > Greg / Kevin, > > Thanks, each of the solution's works. Much appreciated. > > This one appears to need a minor tweak, from: > > import rpy > rpy.r.library("pwr") > rpy.r.pwr_p_test(h=0.2,power=0.95,sig.level=0.05) > > to > > ... sig_level=0.05... > > Which makes sense, given Greg's explanation provided about the dot > versus > the underscore. > > This answers my main question. Thank you! I will drop this side > issue > below out there, as it is what got me stuck, in case it helps > anyone else. > Probably just me being dense. > > > I started down the road of "retrieving an R object is as keywords > of the r > object." I figured this was a viable technique to learn first, in > case "the > first way of retrieving a R object is as attributes of the r > object" put up > a fight. But when I tried: > > r['pwr.p.test(h=0.2,power=0.95,sig.level=0.05)'] > > and similar variations I got something like: > > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "/usr/lib/python2.4/site-packages/rpy.py", line 290, in > __getitem__ > obj = self.__dict__[name] = self.__dict__.get(name, self.get > (name)) > rpy.RException: Error in get(x, envir, mode, inherits) : variable > "pwr.p.test(h=0.2,power=0.95,sig.level=0.05)" was not found > > Is there a way to use the "retrieving an R object is as keywords of > the r > object" approach, given the example here? > > Thanks, > > - Michael > > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.5.472 / Virus Database: 269.9.0/853 - Release Date: > 6/18/2007 > 3:02 PM > > > > ---------------------------------------------------------------------- > --- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > rpy-list mailing list > rpy-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rpy-list ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list