Not able to install rstanarm on Ubuntu 18.04 LTS

On Ubuntu 18.04 + R 3.5.3, you can install rstanarm via the following:

sudo add-apt-repository -y "ppa:marutter/rrutter"
sudo add-apt-repository -y "ppa:marutter/c2d4u3.5"
sudo apt update
sudo apt install r-cran-rstanarm

Some background info on why you may have had trouble previously:

The RStan installation guide for Ubuntu is out of date for those using R 3.5.x.

Ben Goodrich linked in the comments to the RStan GitHub Guide to Installing RStan on Linux. There they advise the following for Ubuntu:

# Add marutter's c2d4u repository, (and rrutter for CRAN builds too)
sudo add-apt-repository -y "ppa:marutter/rrutter"
sudo add-apt-repository -y "ppa:marutter/c2d4u"
sudo apt-get update
sudo apt-get install r-cran-rstan

However, for newer versions of R, you need to instead do the following

# Add marutter's c2d4u repository, (and rrutter for CRAN builds too)
sudo add-apt-repository -y "ppa:marutter/rrutter"
sudo add-apt-repository -y "ppa:marutter/c2d4u3.5"
sudo apt-get update
sudo apt-get install r-cran-rstan

This should install RStan for you just fine on Ubuntu 18.04 + R 3.5.3.


First time when this error occured and assuming that you have a .RProfile in your R root directory you will most likely find a line where it says : setwd("~/R") ,go ahead and comment this line and restart R and get a new session , then run again : install.packages("rstanarm") you should be able to install rstanarm successfully , don't forget to uncomment setwd("~/R") after the installation , the reason of the this error to occur is that rstanarm install script assumes that the working directory is the root of the package directory which not the case when you call setwd() in .Rprofile if you want to give this a try .. please remove the rstanarm that you installed using PPA