lme4 package install failing on Ubuntu 12.04 - r

EDIT :
Many thanks to user20650, whose answer solved this problem. But if anyone knows why the .Rprofile file affects lme4 install on Ubuntu 12.04, please advise because I'd really like to know.
Original post :
I'm attempting to install the doBy package and am having some issues. It depends on lme4, which for some reason is not compiling from any source I've tried so far. I've been to a few links on SO including this one and haven't had any success.
Here are snippets of the errors I'm getting on install. I tried it three different ways, as noted below. Anyone know if something's up with lme4?
Attempt 1:
> install.packages('doBy')
# ...
# ERROR: compilation failed for package ‘lme4’
# * removing ‘/home/richard/R/x86_64-pc-linux-gnu-library/3.1/lme4’
# Warning in install.packages :
# installation of package ‘lme4’ had non-zero exit status
#
# Successfully loaded .Rprofile at Wed May 21 13:33:34 2014
# ERROR: dependency ‘lme4’ is not available for package ‘doBy’
# * removing ‘/home/richard/R/x86_64-pc-linux-gnu-library/3.1/doBy’
# Warning in install.packages :
# installation of package ‘doBy’ had non-zero exit status
Attempt 2:
> install.packages("lme4",repos = "http://r-forge.r-project.org")
# Installing package into ‘/home/richard/R/x86_64-pc-linux-gnu-library/3.1’
# (as ‘lib’ is unspecified)
# Warning in install.packages :
# package ‘lme4’ is not available (for R version 3.1.0)
Attempt 3:
> install_github(repo = 'lme4/lme4', username = 'stevencarlislewalker')
Running Ubuntu 12.04 LTS
> version
# _
# platform x86_64-pc-linux-gnu
# arch x86_64
# os linux-gnu
# system x86_64, linux-gnu
# status
# major 3
# minor 1.0
# year 2014
# month 04
# day 10
# svn rev 65387
# language R
# version.string R version 3.1.0 (2014-04-10)
# nickname Spring Dance

This (possibly) may not be an answer to Richard's Q. but does replicate a problem i had installing lme4 on ubuntu 12,04 on Rv3.1. It would be good if others could reproduce this.
So following on from my comment - noticing that Richard had a .Rprofile, defining .First and .Last in my .Rprofile caused packages not to install.
Exmaple
First uninstall lme4
remove.packages("lme4")
Define .Rprofile file
## .First() run at the start of every R session.
.First <- function() {
cat("\nSuccessfully loaded your .Rprofile at", date(), "\n")
}
## .Last() run at the end of the session
.Last <- function() {
cat("\nGoodbye at ", date(), "\n")
}
Open R
Try an install lme4 - no success & similar error to Richard's above
install.packages("lme4")
...
* removing ‘/home/admin1/R/i686-pc-linux-gnu-library/3.1/lme4’
Warning in install.packages :
installation of package ‘lme4’ had non-zero exit status
So rename (or remove) .Rprofile file in terminal
mv .Rprofile temp.Rprofile
Open R again and try to install lme4
install.packages("lme4")
...
* installing vignettes
** testing if installed package can be loaded
* DONE (lme4)
library(lme4)
# Loading required package: Matrix
# Loading required package: Rcpp

This was a bug, should be fixed by this commit in the development version (on Github) and in release 1.1-7 when it comes out (soon?)

Based on your comments and expanded questions:
You are shooting yourself in the foot by installing R 3.1.0 onto Ubuntu 12.04.
You now run an R that is out of sync with packages like r-cran-lme4 in the distro.
The good news is that you can ask the distribution for information about the so-called Build-Depends it knows, and rebuild lme4 under R 3.1.0
Or can benefit from Michael's other work over at launchpad and use his other repo which is what eg the r-travis code does: sudo add-apt-repository -y "ppa:marutter/rrutter" followed by and sudo add-apt-repository -y "ppa:marutter/c2d4u"
That last step will give you loads of pre-built packages. In the long run you are of course better off being to able to build packages from source yourself...

sudo apt-get install r-base-dev
solved the problem for me

Related

Error message installing Rattle for R on macOS 10.14.1

My R console is 3.5.1. I want to install the rattle package on my Mac Mojave 10.14.1. I realize that you have to install RGtk2 first but still got error messaging even when loaded "from source"
> install.packages("RGtk2")
--- Please select a CRAN mirror for use in this session ---
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘RGtk2’
Do you want to attempt to install these from sources? (Yes/no/cancel) Yes
installing the source package ‘RGtk2’
trying URL 'https://mirrors.nics.utk.edu/cran/src/contrib/RGtk2_2.20.35.tar.gz'
Content type 'application/x-gzip' length 2793137 bytes (2.7 MB)
==================================================
downloaded 2.7 MB
* installing *source* package ‘RGtk2’ ...
** package ‘RGtk2’ successfully unpacked and MD5 sums checked
checking for pkg-config... no
checking for INTROSPECTION... no
checking for GTK... no
configure: error: GTK version 2.8.0 required
ERROR: configuration failed for package ‘RGtk2’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RGtk2’
The downloaded source packages are in
‘/private/var/folders/67/r1c_pfwn5ws6y7rsl2bp_qqh0000gn/T/Rtmpi55PMx/downloaded_packages’
Warning message:
In install.packages("RGtk2") :
installation of package ‘RGtk2’ had non-zero exit status
> install.packages("GTK")
Warning message:
package ‘GTK’ is not available (for R version 3.5.1)
> install.packages("RGtk2", dependencies=TRUE)
Package which is only available in source form, and may need
compilation of C/C++/Fortran: ‘RGtk2’
Do you want to attempt to install these from sources? (Yes/no/cancel) no
This answer is a distillation of content I originally posted on my Johns Hopkins Data Science Specialization Community Mentor Github site in August 2017, in response to student questions about how to install Rattle on OS X in order to produce fancy rpart plots with rattle::fancyRpartPlot().
The install requires the gtk toolkit, and on the Mac one way to accomplish this is, per R 3.0 and GTK+ / RGTK2 Error:
Install macports — tool for installing mac packages
run SUDO to install gtk2 on mac sudo port install gtk2 ## (X11 -- not aqua)
export new path export PATH=/opt/local/bin:/opt/local/sbin:$PATH
From command line R, enter install rgtk2 with install.packages("RGtk2",type="source") to compile from source
Install the rattle packageinstall.packages("rattle",type="source")
NOTE: For the RGtk2 install to work correctly from RStudio, one must first confirm that the PATH change listed above is applied to the shell that is used to start RStudio.
The most complete set of instructions is located at Sebastian Kopf's Gist page and verified by my own install on June 17, 2017. Once installed, loading the rattle library will generate the following output in the R console.
In order to use fancyRpartPlot(), one will also need to install the rpart.plot package.
install.packages("rpart.plot")
Example: Fancy Rpart Plot of Iris Data
Here we've replicated the code needed to generate a fancy tree diagram with caret and rattle that is discussed in the Johns Hopkins Data Science Specialization Practical Machine Learning lecture on Predicting with Trees.
library(caret)
library(rattle)
inTrain <- createDataPartition(y = iris$Species,
p = 0.7,
list = FALSE)
training <- iris[inTrain,]
testing <- iris[-inTrain,]
modFit <- train(Species ~ .,method = "rpart",data = training)
fancyRpartPlot(modFit$finalModel)

Installing BayesLogit package

I am trying to install the BayesLogit package in R. The package was removed from the CRAN website, but I have the source files BayesLogit_0.6.tar.gz. I try running
install.packages("BayesLogit_0.6.tar.gz", type = "source", repos = NULL)
but get the following error: installation of package ‘BayesLogit_0.6.tar.gz’ had non-zero exit status.
Can anyone help, or can you no longer install this package? I have the package installed on another machine, which I installed it back when it was on the CRAN website.
I was able to install the package on my Ubuntu machine with devtools::install_version("BayesLogit", "0.6")
Because the package has C++ source files, you well need compilation tools. If you use Windows, that means you will need to install RTools. On Mac, you will need the Xcode command line tools. See also How do I install a package that has been archived from CRAN? and https://cran.r-project.org/bin/windows/Rtools/
Linux
Run these commands in the R session:
install.packages("devtools") # optional, in case you don't have it
require(devtools)
install_version("BayesLogit", version = "0.6") # the latest version on CRAN archive
macOS
Compiling BayesLogit from source requires GFortran, which requires XCode and command-line tools:
install XCode from the App Store, or install only command-line tools only (e.g., from this thread)
install gfortran, e.g. using an appropriate disk image
run the same code as above inside R:
install.packages("devtools") # optional, in case you don't have it
require(devtools)
install_version("BayesLogit", version = "0.6") # the latest version on CRAN archive
Alternative package
The GitHub page of BayesLogit was last updated 11 months ago, so I venture a guess that it will not be on CRAN. An alternative is this package, which implements the same Polya-Gamma scheme as BayesLogit and has very similar syntax:
# BayesLogit
obj <- BayesLogit::logit(y=y, X=X, P0=diag(rep(precision, ncol(X)), samp=n_samples, burn=burn)
# PolyaGamma
obj <- PolyaGamma::gibbs_sampler(y=y, X=X, lambda=precision, n_iter_total=burn + n_samples, burn_in=burn)
To install the PolyaGamma package, run these commands in your R session:
install.packages("devtools") # optional, in case you don't have it
require(devtools)
devtools::install_github("kasparmartens/PolyaGamma")
library(PolyaGamma)

Installing H2o-3 in R

I use the following code to install h2o-3 in R
# The following two commands remove any previously installed H2O packages for R.
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }
# Next, we download packages that H2O depends on.
pkgs <- c("methods","statmod","stats","graphics","RCurl","jsonlite","tools","utils")
for (pkg in pkgs) {
if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
}
# Now we download, install and initialize the H2O package for R.
install.packages("h2o", type="source", repos=(c("http://h2o-release.s3.amazonaws.com/h2o/rel-turing/3/R")))
library(h2o)
localH2O = h2o.init(nthreads=-1)
# Finally, let's run a demo to see H2O at work.
demo(h2o.kmeans)
It shows the following error.
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.3.1\library" C:\Users\pintoo\AppData\Local\Temp\RtmpUxsC47/downloaded_packages/h2o_3.10.0.3.tar.gz' had status 65535
Warning in install.packages :
installation of package ‘h2o’ had non-zero exit status
Then, as the above code, doesn't install package, and it shows it has been downloaded so i tried installing using the downloaded package using the below code
install.packages("C:/Users/pintoo/AppData/Local/Temp/RtmpUL3Da2/downloaded_packages/h2o_3.10.0.3.tar.gz",
repos = NULL, type = "source", dependencies = T)
It produced the below error
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.3.1\library" "C:/Users/pintoo/AppData/Local/Temp/RtmpUL3Da2/downloaded_packages/h2o_3.10.0.3.tar.gz"' had status 65535
Warning in install.packages :
installation of package ‘C:/Users/pintoo/AppData/Local/Temp/RtmpUL3Da2/downloaded_packages/h2o_3.10.0.3.tar.gz’ had non-zero exit status
MY version :
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 3.1
year 2016
month 06
day 21
svn rev 70800
language R
version.string R version 3.3.1 (2016-06-21)
nickname Bug in Your Hair
Can any one help me out.
What is this non-zero exit status.
status 65535 meaning?
Non- zero exit status of package means?
The error message you gave is for the second of your two install lines; you don't say what happened with the first one.
But, my recommended way to install H2O on R:
install.packages("h2o")
Simple! This will get the latest version from CRAN, and automatically find all the dependencies. The downside is you are a version or so behind the latest. But the product is mature (so being a version back is fine) and development is fairly rapid (so being a version back can sometimes even be better)!
Only use the instructions on the H2O site if you have a good reason to need the latest version. (And I still recommend installing the first time from CRAN, as it is harder to get something wrong, so if that doesn't work, maybe H2O is incompatible with your machine or something like that.)
P.S. The 65535 (i.e. -1) error code is probably a Windows one, and from some googling appears to be a generic one meaning something crashed. If you do pursue it, I'd be suspicious about either access permissions to certain directories, or paths with spaces in them. (IIRC, R used to recommend not installing in directories with spaces in them.)

Installation of package ‘rjags’ had non-zero exit status

S.O.: Linux Ubuntu 14.04 LTS
R: R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: i686-pc-linux-gnu (32-bit)
When I try to install the package rjags, I get the following fatal error:
install.packages("rjags")
Installing package into ‘/home/marco/.rkward/library’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://mirrors.softliste.de/cran/src/contrib/rjags_3-15.tar.gz'
Content type 'application/x-gzip' length 66879 bytes (65 KB)
==================================================
downloaded 65 KB
* installing *source* package ‘rjags’ ...
** package ‘rjags’ successfully unpacked and MD5 sums checked
checking for prefix by checking for jags... no
configure: error: "Location of JAGS headers not defined. Use configure arg '--with-jags-include' or environment variable 'JAGS_INCLUDE'"
ERROR: configuration failed for package ‘rjags’
* removing ‘/home/marco/.rkward/library/rjags’
The downloaded source packages are in
‘/tmp/RtmpditLat/downloaded_packages’
Warning message:
In install.packages("rjags") :
installation of package ‘rjags’ had non-zero exit status
Apparently, the first error message is
configure: error: "Location of JAGS headers not defined. Use configure arg '--with-jags-include' or environment variable 'JAGS_INCLUDE'"
How can I solve this?
As a top comment explained, you need JAGS (Just Another Gibbs Sampler) to be installed in your system. Since you're using Ubuntu 14.04, running
sudo apt-get install jags
should be enough. However, in case you're in another distribution (or, for some reason, the code above doesn't work for you), it's a good idea to know how to get JAGS from the source:
Access http://mcmc-jags.sourceforge.net/
Look for the proper version under "Downloads". For instance, Fedora users should look into the Fedora_20 folder of http://download.opensuse.org/repositories/home:/cornell_vrdc/
Don't forget to download both the base as well as the devel versions.
After the installation is successful, you can go back to R (which can stay open during the whole thing, anyway) and install the package you want.
To me, first, I worked with the installation jags by terminal:
sudo apt-get install jags
and then
install.packages("rjags")
And the error was gone.
1) If necessary Download and install R (https://www.r-project.org/) and potentially a user interface to R like R Studio (see here for tips on getting started with R).
2) Download and install JAGS as per operating system requriements. (http://mcmc-jags.sourceforge.net/)
3) Install additional R packages: e.g., in R install.packages("rjags") . In particular, I use the packages rjags to interface with JAGS and coda to process MCMC output.

Why can't I install the XML package

Am I making some basic error here?
install.packages("XML")
Warning in install.packages :
package ‘XML’ is not available (for R version 2.13.0)
Installing package(s) into ‘C:/Program Files/R/R-2.13.0/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘XML’ is not available (for R version 2.13.0)
It is probably because www.omegahat.org doesn't exist anymore. So,
command install.packages("XML", repos = "http://www.omegahat.org/R")
does not work. Instead use below:
install.packages("XML", repos = "http://www.omegahat.net/R")
There can be two conditions when you see such error:
The package does not exist in the library (you should install it
from it's own library)
The package is not compatible with your R
version (you should change your R version that is compatible, if you
can afford it)
For the first condition, search on internet and read about the package you want to install and check the provider and repository (for this case, XML, it is official R package)
For the second condition, you can find the information in the following link:
http://cran.r-project.org/web/packages/XML/index.html
you can check your R version by typing the following command into your R shell:
version
which will give you all the information, for e.g:
_
platform x86_64-apple-darwin10.8.0
arch x86_64
os darwin10.8.0
system x86_64, darwin10.8.0
status
major 3
minor 0.1
year 2013
month 05
day 16
svn rev 62743
language R
version.string R version 3.0.1 (2013-05-16)
nickname Good Sport
First update the R-core:
version
install.package('installr')
library(installr)
updateR()
Then install the XML module:
install.packages("XML")
What worked for me is downloading the old release of the XML package and installing from the package archive
install.packages("~/R/win-library/3.6/XML_3.99-0.3.zip", repos = NULL, type = "win.binary").

Resources