Hello! The following code does not work. It seems that the R warning message raises a python error.
# enable use of python objects in rpy2
import rpy2.robjects.numpy2ri
import numpy as np
from rpy2.robjects import r
# create an example array
a = np.array([[5,2,5],[3,7,8]])
# this line leads to a warning message, which in turn raises an
# error message if run within a script.
result = r['chisq.test'](a)
Running that code example in ipython works, however, running it inside a script raises the errorTypeError: 'module' object is unsubscriptable. I assume this is due to the warning message.
What is the best way to avoid this problem? Thanks in advance!