How to install Rjags on Ubuntu
Asked Answered
B

1

7

I am trying to install Rjags on Ubuntu, I have first installed this

sudo apt-get install JAGS

Then I have tried

R
install.packages("rjags") 

I have the following error

    > 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

I don't know how to solve this issue, thanks for your help

Andrey Kolyadin, I have followed your instruction, after installing I got this

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) ...

THen I have tried to call the library in R but it is not detected, unfortunately ...

Bartonbartosch answered 28/2, 2018 at 6:17 Comment(5)
I used ppa for it. First add in to the repos sudo add-apt-repository ppa:marutter/rrutter and then sudo apt-get update; sudo apt-get install r-cran-rjags -yOrianna
You are mixing Conda's compiler and the default: x86_64-conda_cos6-linux-gnu-cc. "Bad idea". It installs fine otherwise on Ubuntu.Dennie
Worked with the default repos. See my A.Shipping
Actually I have tried to install it yesterday, but it is not working, the package is said to be installed but when I check it is not. You are right Dirk, I have tried to reinstall everything from scratch R + anaconda + IRkernel (I want to do R with jupyter notebook) but I don't know what happened this time with the package manager condaBartonbartosch
Installing sudo apt -y install jags, then install.packages('rjags') worked fine for me.Testee
S
10

If you installed it from the ppa suggested by andrey, remove it with

sudo apt-add-repository --remove ppa:marutter/rrutter

(Then) update your data:

sudo apt update

and then install it from the default

sudo apt install r-cran-rjags

Test it in R.

R

In R:

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

(probably redundant, just for SEO^^:) Works also for Linux Mint

Shipping answered 28/2, 2018 at 13:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.