I\'m using R
in my Python script through the rpy2
library and I need a package that is not in the default installation of R. How can I install it?
When running pytest
, Aaron's answer makes my Python hang and R keep giving error messages, probably because of this:
Calling
install_packages()
without first choosing a mirror will require the user to interactively choose a mirror.
According to rpy2 documentation, I used this which worked:
from rpy2 import robjects
import rpy2.robjects.packages as rpackages
utils = rpackages.importr('utils')
utils.chooseCRANmirror(ind=1)
utils.install_packages("DirichletReg")
DirichletReg = rpackages.importr("DirichletReg")