how to install rstan in ubuntu 18.04

1.1k Views Asked by At

I'm trying to instal the rstan in Ubuntu 18.04. I started with

 apt-get install r-cran-rstan

and it showed dependence on the packages : r-cran-ggplot2 , r-cran-pkgbuild and r-cran-v8. Then while trying to install all of them, another dependence on r-api-3.5, which I tried to install with

  apt-get install r-api-3.5

Then I saw the following message :

The r-api-3.5 package is a virtual package provided by: r-base-core 3.6.3-1bionic [Not a candidate version]

E: The 'r-api-3.5' package has no candidate for installation

I read some tutorials like this one: Not able to install rstanarm on Ubuntu 18.04 LTS saying I should add the ppa by doing :

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

and I did. But it's still not working. My R version is the latest one. I didn't find documentation about r-api-3.5 in Ubuntu. If anyone knows how to solve it, please tell me.

1

There are 1 best solutions below

1
On

I ran into the same issue and my colleague as well. We just jumped directly to the install and it worked fine. In short:

remove.packages("rstan")
if (file.exists(".RData"))
file.remove(".RData")
install.packages("rstan", repos = "https://cloud.r-project.org/", dependencies = TRUE)
library(rstan)
example(stan_model,run.dontrun = TRUE)

Source and more detailed explanation: https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started#installation-of-rstan