如何在Ubuntu上安装Rjags

7

我正在尝试在Ubuntu上安装Rjags,首先我已经安装了以下软件:

sudo apt-get install JAGS

然后我尝试过:
R
install.packages("rjags") 

我遇到了如下错误

    > install.packages("rjags") 
    Installing package into ‘/home/louis/R/x86_64-pc-linux-gnu-library/3.4’

    (as ‘lib’ is unspecified)
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 71719  100 71719    0     0  46062      0  0:00:01  0:00:01 --:--:-- 46032
    * installing *source* package ‘rjags’ ...
    ** package ‘rjags’ successfully unpacked and MD5 sums checked
    checking for pkg-config... /usr/bin/pkg-config
    configure: Setting compile and link flags according to pkg-config
    configure: Compile flags are -I/usr/include/JAGS
    configure: Link flags are -ljags
    checking for gcc... x86_64-conda_cos6-linux-gnu-cc
    checking whether we are using the GNU C compiler... no
    checking whether x86_64-conda_cos6-linux-gnu-cc accepts -g... no
    checking for x86_64-conda_cos6-linux-gnu-cc option to accept ISO C89... unsupported
    checking for jags_version in -ljags... no
    configure: error: "cannot link to JAGS library in /usr/lib."
    ERROR: configuration failed for package ‘rjags’
    * removing ‘/home/charlie/R/x86_64-pc-linux-gnu-library/3.4/rjags’

    The downloaded source packages are in
        ‘/tmp/Rtmp9yfeon/downloaded_packages’
    Warning message:
    In install.packages("rjags") :
      installation of package ‘rjags’ had non-zero exit status

我不知道如何解决这个问题,感谢您的帮助。

安德烈·科利亚丁,我已经按照您的指示进行操作后,安装完成后出现了以下情况:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be upgraded:
  r-cran-rjags
1 upgraded, 0 newly installed, 0 to remove and 296 not upgraded.
Need to get 88,6 kB of archives.
After this operation, 1 024 B of additional disk space will be used.
Get:1 http://ppa.launchpad.net/marutter/rrutter/ubuntu xenial/main amd64 r-cran-rjags amd64 1:4.6-1cran4ubuntu1ppa1~ubuntu16.04.1~ppa1 [88,6 kB]
Fetched 88,6 kB in 1s (68,8 kB/s)       
(Reading database ... 250343 files and directories currently installed.)
Preparing to unpack .../r-cran-rjags_1%3a4.6-1cran4ubuntu1ppa1~ubuntu16.04.1~ppa1_amd64.deb ...
Unpacking r-cran-rjags (1:4.6-1cran4ubuntu1ppa1~ubuntu16.04.1~ppa1) over (1:4-5-1) ...
Setting up r-cran-rjags (1:4.6-1cran4ubuntu1ppa1~ubuntu16.04.1~ppa1) ...

然后我试图在R中调用该库,但不幸的是它没有被检测到...


3
我使用了ppa。首先将其添加到存储库中 sudo add-apt-repository ppa:marutter/rrutter,然后运行 sudo apt-get update; sudo apt-get install r-cran-rjags -y 进行安装。 - Andrey Kolyadin
1
你正在混合使用Conda的编译器和默认编译器:x86_64-conda_cos6-linux-gnu-cc。这是“不好的想法”。否则,在Ubuntu上安装是没有问题的。 - Dirk Eddelbuettel
使用默认仓库进行工作。请查看我的 A。 - loki
实际上,我昨天尝试安装它了,但是它没有工作,包被说已经安装,但是当我检查时却没有。你是对的Dirk,我尝试从头重新安装所有东西,包括R + anaconda + IRkernel(我想用jupyter笔记本做R),但是这次使用包管理器conda时出了问题,我不知道发生了什么。 - glouis
我安装sudo apt -y install jags,然后install.packages('rjags'),对我来说运行得很好。 - undefined
1个回答

10
如果您是按照安德烈建议的ppa安装的,请使用以下命令卸载它: sudo apt-add-repository --remove ppa:marutter/rrutter 然后更新您的数据:
sudo apt update

然后从默认位置安装它。

sudo apt install r-cran-rjags

在 R 中进行测试。

R

在R中:

>library(rjags)
# Loading required package: coda
# Linked to JAGS 4.2.0
# Loaded modules: basemod,bugs

(可能是多余的,只是为了SEO^^:) 也适用于Linux Mint。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接