0

I tried to create a function for the following

from pyper import *
import pandas as pd

r=R(use_pandas=True)
r.assign('xN', 5)
r.assign('yN', 3)
r('out1 <- xN + yN')
print(r.get('out1'))
8

created function

def addR(x, y):
    r=R(use_pandas=True)
    r.assign('xR', x)
    r.assign('yR', y)
    return r('out <- xR + yR')

addR(5, 3)
r=R(use_pandas=True)
print(r.get('out'))
None

is returning None

  • This is confusing. This is running in python? I'm not sure why you're calling `get()` on the output – roganjosh Aug 29 '18 at 15:30
  • You'll have to get a better understanding of variables scopes ... the `r` you are defining in the function is lost, the one you are printing is a new and empty one. Maybe you would like to do something like `r=addR(5, 3);print(r.get('out'))` – Lohmar ASHAR Aug 29 '18 at 15:33

0 Answers0