The normal way to make the call to an r function using rpy is to call it like so:

        import rpy
        rpy.r.function_name(a=1, b=2, c=4)

note that in R, the period character '.' is a valid part of names, while in python it is not. To overcome this problem, rpy translates the underscore character '_' to a period '.'. Thus to call the function named 'pwr.p.test' you would use the python syntax:

        import rpy
        rpy.r.library("pwr")
        rpy.r.pwr_p_test(h=0.2,power=0.95,sig.level=0.05)

-Greg

On Jun 17, 2007, at 1:21PM , <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote:



I am a new user of RPy, just having completed a build of it on Debian Etch using 1.0-RC1 and R-2.51. All seems to be running fine on the R side and the RPY side, but I am struggling a bit with syntax for parameters passing, and I am not able to find a question on the mailing list to assist.



Quick version: I run the following (after loading the ‘pwr’ module) directly from R, and it works in R:



> pwr.p.test(h=0.2,power=0.95,sig.level=0.05)



With the following nice output:



…power calculation for binomial distribution (arcsine transformation)



              h = 0.2

              n = 324.8677

      sig.level = 0.05

          power = 0.95

    alternative = two.sided





Using RPy, I am able to load the library OK



>>> r.library('pwr')

['pwr', 'stats', 'graphics', 'grDevices', 'utils', 'datasets', 'methods', 'base']



And I am able to create Robjs using that library:



>>> r['pwr.p.test']

<Robj object at 0xb7e141d0>



But I can’t sort out the right want to pass arguments to the object (i.e., h=0.2,power=0.95,sig.level=0.05). I have tried various dictionary and list forms, but no luck so far, just many errors. I am suspecting it is about position dependency in the call, but I am struggling with how to compensate for this.



Any suggestions from those in the know?



Much thanks,



-          Michael





(for what’s its worth, python 2.4.4, Debian Etch, RPy 1.0-RC1 on x86 seems to work, which was a question I had, when build from Etch sources, but not using Etch binaries. I am not thinking this is rekatred to my problem, as other examples run OK).




No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.9.0/851 - Release Date: 6/16/2007 12:50 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/
<mime-attachment.txt>

-------------------------------------------------------------------------
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

Reply via email to