如何在ubuntu 18.04中安装rstan

问题描述

我正在尝试在Ubuntu 18.04中安装rstan。我从

开始
 apt-get install r-cran-rstan

显示出对软件包的依赖:r-cran-ggplot2,r-cran-pkgbuild和r-cran-v8。 然后,在尝试安装所有组件时,又出现了对r-api-3.5的依赖,我尝试使用r-api-3.5进行安装

  apt-get install r-api-3.5

然后我看到以下消息:

r-api-3.5软件包是由以下人员提供的虚拟软件包:r-base-core 3.6.3-1bionic [非候选版本]

E:“ r-api-3.5”软件包没有安装候选对象

我阅读了一些类似这样的教程:Not able to install rstanarm on Ubuntu 18.04 LTS说我应该这样做:

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

我做到了。但它仍然无法正常工作。我的R版本是最新版本。我在Ubuntu中找不到有关r-api-3.5的文档。如果有人知道如何解决,请告诉我。

解决方法

我和我的同事也遇到了同样的问题。 我们只是直接跳到安装,它运行良好。 简而言之:

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)

来源和更详细的说明:https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started#installation-of-rstan