I am trying to install R package on python 3x in the jupyter notebook.
I understand that I have to pip install rpy2 and it has been successful
This works fine when I call a built-in function in R such as ccf or other easy issues.
# Call function from R
import os
os.environ['R_USER'] = 'D:\Anaconda3\Lib\site-packages\rpy2'
import rpy2.robjects as robjects
from rpy2.robjects import pandas2ri
pandas2ri.activate()
However, if I want to install a package such as DirichletReg
or vars
, it is not that easy especially that there might be more packages that are required to be downloaded.
I indeed followed the link as described in
R, Python: install packages on rpy2
from rpy2.robjects.packages import importr
utils = importr('utils')
utils.install_packages('DirichletReg')
but received the following RuntimeError
---------------------------------------------------------------------------
RRuntimeError Traceback (most recent call last)
<ipython-input-16-32acf37e1ef9> in <module>()
1 from rpy2.robjects.packages import importr
2 utils = importr('utils')
----> 3 utils.install_packages('DirichletReg')
D:\Anaconda3\lib\site-packages\rpy2\robjects\functions.py in __call__(self, *args, **kwargs)
176 v = kwargs.pop(k)
177 kwargs[r_k] = v
--> 178 return super(SignatureTranslatedFunction, self).__call__(*args, **kwargs)
179
180 pattern_link = re.compile(r'\\link\{(.+?)\}')
D:\Anaconda3\lib\site-packages\rpy2\robjects\functions.py in __call__(self, *args, **kwargs)
104 for k, v in kwargs.items():
105 new_kwargs[k] = conversion.py2ri(v)
--> 106 res = super(Function, self).__call__(*new_args, **new_kwargs)
107 res = conversion.ri2ro(res)
108 return res
RRuntimeError: Error in (function (pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos, :
py2/R/win-library/3.3'\Anaconda3\Lib\site-packages
did anyone found this difficulty earlier?