Install R in Linux/Unix Without Having Root Privilage

How to set up R to run from a directory with no bin or root access?

Yes, This can be easily done as follows:

wget http://cran.r-project.org/src/base/R-3/R-3.5.1.tar.gz

# untar the sources
tar xzvf R-3.5.1.tar.gz
cd R-3.5.1

# configure
./configure --prefix=/path/to/your/local/dir/install --enable-R-shlib --enable-memory-profiling --enable-R-profiling --with-valgrind-instrumentation=2

# build R
make

# install
make install

Once you build your own version of R, set environment variables:

export PATH=/path/to/your/local/dir/install/bin:$PATH
export R_HOME=/path/to/your/local/dir/install/lib64/R

These variables need to be set every time you want to use your own version of R.

Is it possible to install Rstudio server on Linux without root access?

No, you can't install it without root access. But there are a couple of things you could do to piece together a solution. Here are two options:

Extract the server and run it directly

You have to be root to install packages, so you can't install the .deb/.rpm file yourself. However, you could extract the contents of the file to a directory inside your home directory and run RStudio Server from there, by executing the rserver program in a regular shell.

Note that this will probably require an afternoon of editing the rserver.conf file to tell it where to find the rest of the files in the installation (since it presumes they are installed in /usr/lib by default). You can get some inspiration for how to do this here: https://github.com/rstudio/rstudio/blob/master/src/cpp/conf/rserver-dev.conf

Run the desktop version and forward the graphics

The other route is to run RStudio Desktop on the server; we make several builds of RStudio Desktop that are installer-less and can just be unpacked into your home directory. Then run an X11 server on your own computer and an X11 client on the RStudio server, so that the RStudio Desktop instance appears on your computer instead of the server.

How to install R on a linux cluster?

I'm not sure this is on-topic, but: all you really have to do is

  • download the R source tarball from CRAN; unpack it somewhere in your file space
  • create an r-build directory at the same level of the hierarchy (not technically necessary, but it's better practice to keep the source and build directories separate)
  • create an installation directory (say ~/r_install) somewhere sensible within your file space
  • cd to the source directory; tools/rsync-recommended
  • cd to the build directory
  • ../[srcdir]/configure --prefix=~/r_install
  • make (to build the binaries)
  • make install (to move everything where it belongs; not technically necessary, as you can run R from the build directory)

Where this may get hairy is with all of the system requirements for R (LaTeX, Java, bzip2, etc. etc. ...) it is theoretically possible to download all this stuff and install it in your own file space, but it starts to get sufficiently tedious that it will be easier to beg your sysadmin to install at least the dependencies for you ...

as @Hack-R points out the basics of this answer are already present on Unix & Linux stackexchange, although my answer is a little more detailed ...

Where to install R packages on Linux server that are to be used by multiple users?

I've never tried this, but I don't see why this wouldn't work:

You can use .libPaths() to set the library dir (not only to get it), so why don't you have everyone use a common directory that's writeable by everyone as the libpath? Every user can put in their .Rprofile something like

.libPaths( c(.libPaths(), "/path/to/shared/lib") )

Then that path will be the default place where everyone installs/retrieves packages from.

One problem with this approach is that people will still have their original libPath per person, so if they're trying to update an existing package, it'll update their own version. You can overcome that by setting the libpath to ONLY the new path instead of appending to it.

Note that this can sometimes have bad consequences, sometimes person A's code depends on a certain version of a package, then person B updates the package, then person A runs his code again 5 minutes later and all of a sudden it breaks and they have absolutely no idea why.

Best way to install R on Ubuntu 20.04?

Here is what I do in the Rocker container r-ubuntu for the 20.04 image:

  1. Install software-properties-common to be able to say add-apt-repository

  2. Add the rrutter4.0 PPA for R itself (same as CRAN)

    add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0"

  3. Add the c4d4u.teams repo for over 4k CRAN packages:

    add-apt-repository --enable-source --yes "ppa:c2d4u.team/c2d4u4.0+"

  4. Run apt install r-base (and a few more).

In a narrow sense you only need 2 (as you likely do not 1 on a full Ubuntu system) and 4 but you may as well do 3.

You can of course also just to docker pull rocker/r-ubuntu:20.04 and get that container pre-made, but I use both: a container for tests, and these settings on my 20.04 machine(s).



Related Topics



Leave a reply



Submit