R, Python: install packages on rpy2

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?

install.packages("DirichletReg", repos="http://r-forge.r-project.org")

won't work.

On Python:

>>> install.packages("DirichletReg", repos="http://r-forge.r-project.org") 
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'install' is not defined

And from R:

> install.packages("DirichletReg", repos="http://r-forge.r-project.org")
Installing package(s) into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘DirichletReg’ is not available (for R version 2.14.1)


How about this

>>> import rpy2.interactive as r
>>> r.importr("utils")
>>> package_name = "DirichletReg"
>>> r.packages.utils.install_packages(package_name)

Ricardo's answer no longer works.

To install from Python:

from rpy2.robjects.packages import importr
utils = importr('utils')

That utils package is the R.utils package whose documentation can be found here: https://CRAN.R-project.org/package=R.utils

As of my last edit, the documentation still says to do this.

Need Your Help

Change bits value in Byte


I have some data in field type Byte ( I save eight inputs in Byte, every bit is one input ).

How do you determine the ideal buffer size when using FileInputStream?

java performance file-io filesystems buffer

I have a method that creates a MessageDigest (a hash) from a file, and I need to do this to a lot of files (>= 100,000). How big should I make the buffer used to read from the files to maximize