Skip to content

Instantly share code, notes, and snippets.

@thekensta
Created November 13, 2015 10:30
Show Gist options
  • Save thekensta/538a3c6e3f0faf43b89c to your computer and use it in GitHub Desktop.
Save thekensta/538a3c6e3f0faf43b89c to your computer and use it in GitHub Desktop.
Call power.prop.test via Python
# Need to change the values extracted, serves as aide-memoire for R <-> Python
def parse_robj(obj):
"""Extract n, p1 and p2 from R List from power.prop.test. """
return (obj[obj.names.index("n")][0],
obj[obj.names.index("p1")][0],
obj[obj.names.index("p2")][0])
def call_power_prop_test(p1, n):
P__ = %R power.prop.test(p1=$p1, n=$n, power=0.8)
return parse_robj(P__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment