-1
import rpy2
import rpy2.robjects as ro
from rpy2.robjects.packages import importr
import rpy2.robjects.numpy2ri

it gives the error as

ValueError: r_home is None. Try python -m rpy2.situation

the last call is

File "/home/phantom/anaconda3/envs/spa/lib/python3.9/site-packages/rpy2/rinterface_lib/openrlib.py", line 16, in _dlopen_rlib

1 Answers1

0

You need to set an environment variable called R_Home with the the path directory to R.

import os
os.environ['R_HOME'] = '/path/to/R'
import rpy2
import rpy2.robjects as ro
from rpy2.robjects.packages import importr
import rpy2.robjects.numpy2ri