How can I install a new version of R in my own directory, e.g.,
The easiest way to do this is to install R from source:
$ wget http://cran.rstudio.com/src/base/R-3/R-3.4.1.tar.gz $ tar xvf R-3.4.1.tar.gz $ cd R-3.4.1 $ ./configure --prefix=$HOME/R $ make && make install
The second-to-last step is the critical one. It configures R to be installed into a subdirectory of your own home directory.
To run it on Linux, macOS and similar systems, add
$HOME/R/bin to your
PATH. Then, shell commands like
Rscript will work.
On macOS, you have another alternative: build
R.app and install it into your user's private
Applications folder. You need to have Xcode installed to do this.
You might consider giving
--prefix=$HOME instead. That installs R at the top level of your home directory, so that the
Rscript binaries end up in
$HOME/bin, which is likely already in your user's
PATH. The downside is that it makes later uninstallation harder, since R would be intermingled among your other
(If this is the first thing you've installed to
$HOME/bin, you might have to log out and back in to get this in your
PATH, since it's often added conditionally only if
$HOME/bin exists at login time.)
This general pattern applies to a large amount of Unix software you can install from source code. If the software has a
configure script, it probably understands the
--prefix option, and if not, there is usually some alternative with the same effect.
These features are common for a number of reasons. In decreasing order of likelihood, in my experience:
The safe default (
/usr/local) is not the right
$prefixin all situations. Circumstances might dictate something else such as
Binary package building systems (RPM, DEB, PKG, Cygport...) typically build and install the package into a special staging directory, then pack that up in such a way that it expands into the desired installation location.
Your case, where you can't get
rootto install the software into a typical location, so you install into
You can also use the wrapper application Renv.
Simple R Version Management: Renv
Renv lets you easily switch between multiple versions of R. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.
- Let you change the global R version on a per-user basis.
- Provide support for per-project R versions.
- Allow you to override the R version with an environment variable.
Build from source with
./configure --prefix=/local/data/project/behi ; make ; make install
If you're installing from an RPM package and it was created relocatable, you could use
rpm ... --prefix /local/data/project/behi
But not all packages are built with relocatable binaries, and I don't think debian packages have this option (although you might succeed with