How to install packages in R or Rstudio - r

when trying to install a package:
> install.packages("mlr")
Installing package into ‘/home/kisco/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
dependencies ‘plyr’, ‘dplyr’, ‘lazyeval’ are not available
also installing the dependencies ‘scales’, ‘ggplot2’, ‘ggvis’, ‘reshape2’
trying URL 'http://cran.rstudio.com/src/contrib/scales_0.2.5.tar.gz'
Content type 'application/x-gzip' length 56346 bytes (55 Kb)
opened URL
==================================================
downloaded 55 Kb
trying URL 'http://cran.rstudio.com/src/contrib/ggplot2_1.0.1.tar.gz'
Content type 'application/x-gzip' length 2351203 bytes (2.2 Mb)
opened URL
==================================================
downloaded 2.2 Mb
trying URL 'http://cran.rstudio.com/src/contrib/ggvis_0.4.2.tar.gz'
Content type 'application/x-gzip' length 728345 bytes (711 Kb)
opened URL
==================================================
downloaded 711 Kb
trying URL 'http://cran.rstudio.com/src/contrib/reshape2_1.4.1.tar.gz'
Content type 'application/x-gzip' length 34693 bytes (33 Kb)
opened URL
==================================================
downloaded 33 Kb
trying URL 'http://cran.rstudio.com/src/contrib/mlr_2.4.tar.gz'
Content type 'application/x-gzip' length 440988 bytes (430 Kb)
opened URL
==================================================
downloaded 430 Kb
ERROR: dependency ‘plyr’ is not available for package ‘scales’
* removing ‘/home/kisco/R/x86_64-pc-linux-gnu-library/3.0/scales’
Warning in install.packages :
installation of package ‘scales’ had non-zero exit status
ERROR: dependencies ‘dplyr’, ‘lazyeval’ are not available for package ‘ggvis’
* removing ‘/home/kisco/R/x86_64-pc-linux-gnu-library/3.0/ggvis’
Warning in install.packages :
installation of package ‘ggvis’ had non-zero exit status
ERROR: dependency ‘plyr’ is not available for package ‘reshape2’
* removing ‘/home/kisco/R/x86_64-pc-linux-gnu-library/3.0/reshape2’
Warning in install.packages :
installation of package ‘reshape2’ had non-zero exit status
ERROR: dependencies ‘plyr’, ‘reshape2’, ‘scales’ are not available for package ‘ggplot2’
* removing ‘/home/kisco/R/x86_64-pc-linux-gnu-library/3.0/ggplot2’
Warning in install.packages :
installation of package ‘ggplot2’ had non-zero exit status
ERROR: dependencies ‘ggplot2’, ‘ggvis’, ‘plyr’, ‘reshape2’ are not available for package ‘mlr’
removing ‘/home/kisco/R/x86_64-pc-linux-gnu-library/3.0/mlr’
Warning in install.packages :
installation of package ‘mlr’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmp3AjleG/downloaded_packages’
I keep getting th eerror" warning in install.packages insallation of package ... had non zero exit status.
What am I doing wrong? How do I Install MLR?

You have an outdated version of R. Normally dplyr and your other dependencies would be automatically installed, but in this case they are labelled as not working with older versions of R, so throw an error.
You have version 3.0.2, which is out of date. As of now the current version is 3.2.1. You should upgrade (you don't have the most up to date version of r-base, repos are often behind - try getting the binary from here).
If you don't want to update you can use the methods described in answers to this question to install older versions of the packages which may be compatible with your version - install older version of R package.

Related

R doesn't work properly with conda installation

I tried installing r with conda and every time I try that it doesn't work.
conda create --name test2 -c conda-forge r-base r-seurat
I assumed that by using conda-forge channel, it will install the most updated version. What happened is that it installs the oldest version of R which is 3.6.1
At the same time, the "Seurat" package requires a newer version of R than 3.6.1
So, I specified a version of R in that code and it didn't work too
conda create --name test2 -c conda-forge r-base=4.1.1
This worked for installing a newer R version but when I try activating R on that environment, it gives me an error
Error in library(beepr) : there is no package called ‘beepr’
So, I opened rstudio from that environment and tried installing (beepr) package and it didn't work! It tries to install other packages as a requirement for it and at the same time gives the same error of not having "beepr" installed.
That's one of the packages it tried to install.
Warning in install.packages : installation of package ‘glue’ had non-zero exit status Error in library(beepr) : there is no package called ‘beepr’ Execution halted
and it does that with the rest of packages required.
That's the error I get from installing beepr
also installing the dependencies ‘glue’, ‘magrittr’, ‘stringi’, ‘stringr’, ‘audio’ trying URL 'https://cran.rstudio.com/src/contrib/glue_1.4.2.tar.gz' Content type 'application/x-gzip' length 99049 bytes (96 KB) ================================================== downloaded 96 KB trying URL 'https://cran.rstudio.com/src/contrib/magrittr_2.0.1.tar.gz' Content type 'application/x-gzip' length 265580 bytes (259 KB) ================================================== downloaded 259 KB trying URL 'https://cran.rstudio.com/src/contrib/stringi_1.7.4.tar.gz' Content type 'application/x-gzip' length 7599762 bytes (7.2 MB) ================================================== downloaded 7.2 MB trying URL 'https://cran.rstudio.com/src/contrib/stringr_1.4.0.tar.gz' Content type 'application/x-gzip' length 135777 bytes (132 KB) ================================================== downloaded 132 KB trying URL 'https://cran.rstudio.com/src/contrib/audio_0.1-8.tar.gz' Content type 'application/x-gzip' length 57390 bytes (56 KB) ================================================== downloaded 56 KB trying URL 'https://cran.rstudio.com/src/contrib/beepr_1.3.tar.gz' Content type 'application/x-gzip' length 922244 bytes (900 KB) ================================================== downloaded 900 KB Error in library(beepr) : there is no package called ‘beepr’ Execution halted Warning in install.packages : installation of package ‘glue’ had non-zero exit status Error in library(beepr) : there is no package called ‘beepr’ Execution halted Warning in install.packages : installation of package ‘magrittr’ had non-zero exit status Error in library(beepr) : there is no package called ‘beepr’ Execution halted Warning in install.packages : installation of package ‘stringi’ had non-zero exit status Error in library(beepr) : there is no package called ‘beepr’ Execution halted Warning in install.packages : installation of package ‘audio’ had non-zero exit status Error in library(beepr) : there is no package called ‘beepr’ Execution halted Warning in install.packages : installation of package ‘stringr’ had non-zero exit status Error in library(beepr) : there is no package called ‘beepr’ Execution halted Warning in install.packages : installation of package ‘beepr’ had non-zero exit status The downloaded source packages are in ‘/tmp/Rtmp0CeBTl/downloaded_packages’ Updating HTML index of packages in '.Library' Making 'packages.html' ... done Warning in install.packages : converting NULL pointer to R NULL Warning message: R graphics engine version 14 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.
Did anyone face that issue before?

dependency 'quadprog' is not available for installing package 'bfast'

i am trying to install the package "bfast" in R studio running R 3.5.3 and it throws up dependency error Warning in install.packages :
dependency ‘quadprog’ is not available
i tried installing it using install.packages("bfast") and when i received the dependency error, i tried to install quadprog dependency as a package seperately like install.packages("quadprog") but then it showed me this error,Warning in install.packages :
package ‘quadprog’ is not available (for R version 3.5.3)
here is the console status while installing bfast package.
install.packages("bfast")
Installing package into ‘/home/rehan/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
Warning in install.packages :
dependency ‘quadprog’ is not available
also installing the dependencies ‘tseries’, ‘forecast’
trying URL 'https://cloud.r-project.org/src/contrib/tseries_0.10-46.tar.gz'
Content type 'application/x-gzip' length 164471 bytes (160 KB)
==================================================
downloaded 160 KB
trying URL 'https://cloud.r-project.org/src/contrib/forecast_8.6.tar.gz'
Content type 'application/x-gzip' length 908972 bytes (887 KB)
==================================================
downloaded 887 KB
trying URL 'https://cloud.r-project.org/src/contrib/bfast_1.5.7.tar.gz'
Content type 'application/x-gzip' length 59697 bytes (58 KB)
==================================================
downloaded 58 KB
ERROR: dependency ‘quadprog’ is not available for package ‘tseries’
* removing ‘/home/rehan/R/x86_64-pc-linux-gnu-library/3.5/tseries’
Warning in install.packages :
installation of package ‘tseries’ had non-zero exit status
ERROR: dependency ‘tseries’ is not available for package ‘forecast’
* removing ‘/home/rehan/R/x86_64-pc-linux-gnu-library/3.5/forecast’
Warning in install.packages :
installation of package ‘forecast’ had non-zero exit status
ERROR: dependency ‘forecast’ is not available for package ‘bfast’
* removing ‘/home/rehan/R/x86_64-pc-linux-gnu-library/3.5/bfast’
Warning in install.packages :
installation of package ‘bfast’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpSfjWA6/downloaded_packages’
How can i properly install the package with all it's dependencies?
I just had the same problem. I looked where R was looking from (https://cran.rstudio.com/bin/windows/contrib/3.5/) and downloaded the 'quadprog' zip file from there. Then, in R or Rstudio, you go to install packages from "package archive file". It worked for me, I hope it does for you.
There is a new version of Quadprog: 1.5-7 that can install on R above 3.1:https://cran.r-project.org/web/packages/quadprog/index.html
That solved it for me.

error in install.package("phia")

I am running macOS High Sierra: 10.13.3 and RStudio: 1.1.383
I am trying to install the package "phia" to use the interactionMeans
I have tried changing my mirror to no avail
However, I get this error;
> install.packages("phia", repos="http://cran.r-project.org",
dependencies = T)
also installing the dependencies ‘rio’, ‘car’
There are binary versions available but the source versions are
later:
binary source needs_compilation
rio 0.5.5 0.5.10 FALSE
car 2.1-6 3.0-0 FALSE
trying URL 'http://cran.r-
project.org/bin/macosx/mavericks/contrib/3.3/phia_0.2-1.tgz'
Content type 'application/x-gzip' length 570570 bytes (557 KB)
==================================================
downloaded 557 KB
The downloaded binary packages are in /var/fo
lders/73/gmd2dyv53bq9z861m7x1v09h0000gn/T//Rtmp23hrdR/downloaded_pa
ckages
installing the source packages ‘rio’, ‘car’
trying URL 'http://cran.r-project.org/src/contrib/rio_0.5.10.tar.gz'
Content type 'application/x-gzip' length 70117 bytes (68 KB)
==================================================
downloaded 68 KB
trying URL 'http://cran.r-project.org/src/contrib/car_3.0-0.tar.gz'
Content type 'application/x-gzip' length 443887 bytes (433 KB)
==================================================
downloaded 433 KB
* installing *source* package ‘rio’ ...
** package ‘rio’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
Error : object ‘read_xls’ is not exported by 'namespace:readxl'
ERROR: lazy loading failed for package ‘rio’
* removing
‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rio’
Warning in install.packages :
installation of package ‘rio’ had non-zero exit status
ERROR: dependency ‘rio’ is not available for package ‘car’
* removing
‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/car’
Warning in install.packages :
installation of package ‘car’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/73/gmd2dyv53bq9z861m7x1v09h0000gn/T/Rtmp23hrdR/downloaded_packages’
If anyone has any ideas please fire them at me!

car package in Ubuntu machine 16.04

I can't install car package in R in an Ubuntu VM 16.04.
My last attempt was through terminal console of R.
The same result when I try to run it through R studio or using devtools
I receive the following errors:
> install.packages('car')
Installing package into ‘/home/stefan/R/x86_64-pc-linux-gnu-library/3.2’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
also installing the dependencies ‘nloptr’, ‘lme4’, ‘pbkrtest’
trying URL 'https://ftp.cc.uoc.gr/mirrors/CRAN/src/contrib/nloptr_1.0.4.tar.gz'
Content type 'application/octet-stream' length 353957 bytes (345 KB)
==================================================
downloaded 345 KB
trying URL 'https://ftp.cc.uoc.gr/mirrors/CRAN/src/contrib/lme4_1.1-15.tar.gz'
Content type 'application/octet-stream' length 3610706 bytes (3.4 MB)
==================================================
downloaded 3.4 MB
trying URL 'https://ftp.cc.uoc.gr/mirrors/CRAN/src/contrib/pbkrtest_0.4-7.tar.gz'
Content type 'application/octet-stream' length 156406 bytes (152 KB)
==================================================
downloaded 152 KB
trying URL 'https://ftp.cc.uoc.gr/mirrors/CRAN/src/contrib/car_2.1-6.tar.gz'
Content type 'application/octet-stream' length 627349 bytes (612 KB)
==================================================
downloaded 612 KB
ERROR: failed to lock directory ‘/home/stefan/R/x86_64-pc-linux-gnu-library/3.2’ for modifying
Try removing ‘/home/stefan/R/x86_64-pc-linux-gnu-library/3.2/00LOCK-nloptr’
ERROR: dependency ‘nloptr’ is not available for package ‘lme4’
* removing ‘/home/stefan/R/x86_64-pc-linux-gnu-library/3.2/lme4’
ERROR: dependency ‘lme4’ is not available for package ‘pbkrtest’
* removing ‘/home/stefan/R/x86_64-pc-linux-gnu-library/3.2/pbkrtest’
ERROR: dependency ‘pbkrtest’ is not available for package ‘car’
* removing ‘/home/stefan/R/x86_64-pc-linux-gnu-library/3.2/car’
The downloaded source packages are in
‘/tmp/RtmpXR2ZjI/downloaded_packages’
Warning messages:
1: In install.packages("car") :
installation of package ‘nloptr’ had non-zero exit status
2: In install.packages("car") :
installation of package ‘lme4’ had non-zero exit status
3: In install.packages("car") :
installation of package ‘pbkrtest’ had non-zero exit status
4: In install.packages("car") :
installation of package ‘car’ had non-zero exit status

install.package() on RStudio on Amazon EC2 doesn't work. Package not available for R version 3.3.3

I've seen this: How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?
and been through the list. No luck. I've also navigated via SSH to my library to see if there was some LOCK file or corrupt install. There is nothing there.
I literally just installed RStudio on Amazon EC2 and can't install the any new packages.
I've done it this way: https://aws.amazon.com/blogs/big-data/running-r-on-aws/
I've also used Ubuntu with Louis Anslett's AMI: http://www.louisaslett.com/RStudio_AMI/
I get the same problem in both. I have downloaded them manually and installed the tar.gz files from the temp directory. The CRAN repository seems to be fine because install.packages() downloads the tar.gz to /tmp/Rtmp2Rh9Zr/downloaded_packages/ just fine, but then the actual install process fails.
When I run install.packages("haven") for instance, it says
> install.packages("haven")
Installing package into ‘/home/jblocher/R/x86_64-redhat-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
also installing the dependencies ‘R6’, ‘assertthat’, ‘rlang’, ‘Rcpp’, ‘readr’, ‘hms’, ‘tibble’, ‘BH’
trying URL 'https://cran.rstudio.com/src/contrib/R6_2.2.1.tar.gz'
Content type 'application/x-gzip' length 325641 bytes (318 KB)
==================================================
downloaded 318 KB
trying URL 'https://cran.rstudio.com/src/contrib/assertthat_0.2.0.tar.gz'
Content type 'application/x-gzip' length 11612 bytes (11 KB)
==================================================
downloaded 11 KB
trying URL 'https://cran.rstudio.com/src/contrib/rlang_0.1.1.tar.gz'
Content type 'application/x-gzip' length 201419 bytes (196 KB)
==================================================
downloaded 196 KB
trying URL 'https://cran.rstudio.com/src/contrib/Rcpp_0.12.11.tar.gz'
Content type 'application/x-gzip' length 2485092 bytes (2.4 MB)
==================================================
downloaded 2.4 MB
trying URL 'https://cran.rstudio.com/src/contrib/readr_1.1.1.tar.gz'
Content type 'application/x-gzip' length 233793 bytes (228 KB)
==================================================
downloaded 228 KB
trying URL 'https://cran.rstudio.com/src/contrib/hms_0.3.tar.gz'
Content type 'application/x-gzip' length 7271 bytes
==================================================
downloaded 7271 bytes
trying URL 'https://cran.rstudio.com/src/contrib/tibble_1.3.1.tar.gz'
Content type 'application/x-gzip' length 91235 bytes (89 KB)
==================================================
downloaded 89 KB
trying URL 'https://cran.rstudio.com/src/contrib/BH_1.62.0-1.tar.gz'
Content type 'application/x-gzip' length 10181096 bytes (9.7 MB)
==================================================
downloaded 9.7 MB
trying URL 'https://cran.rstudio.com/src/contrib/haven_1.0.0.tar.gz'
Content type 'application/x-gzip' length 150016 bytes (146 KB)
==================================================
downloaded 146 KB
Error in library(haven) : there is no package called ‘haven’
Execution halted
Warning in install.packages :
installation of package ‘R6’ had non-zero exit status
Error in library(haven) : there is no package called ‘haven’
Execution halted
Warning in install.packages :
installation of package ‘assertthat’ had non-zero exit status
Error in library(haven) : there is no package called ‘haven’
Execution halted
Warning in install.packages :
installation of package ‘rlang’ had non-zero exit status
Error in library(haven) : there is no package called ‘haven’
Execution halted
Warning in install.packages :
installation of package ‘Rcpp’ had non-zero exit status
Error in library(haven) : there is no package called ‘haven’
Execution halted
Warning in install.packages :
installation of package ‘hms’ had non-zero exit status
Error in library(haven) : there is no package called ‘haven’
Execution halted
Warning in install.packages :
installation of package ‘BH’ had non-zero exit status
Error in library(haven) : there is no package called ‘haven’
Execution halted
Warning in install.packages :
installation of package ‘tibble’ had non-zero exit status
Error in library(haven) : there is no package called ‘haven’
Execution halted
Warning in install.packages :
installation of package ‘readr’ had non-zero exit status
Error in library(haven) : there is no package called ‘haven’
Execution halted
Warning in install.packages :
installation of package ‘haven’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmpia0VEs/downloaded_packages’
When I install it using the already downloaded package, it says
> install.packages("/tmp/Rtmp2Rh9Zr/downloaded_packages/haven_1.0.0.tar.gz")
Installing package into ‘/home/jblocher/R/x86_64-redhat-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘/tmp/Rtmp2Rh9Zr/downloaded_packages/haven_1.0.0.tar.gz’ is not available (for R version 3.3.3)
If you are providing an archive file to install.packages you may need to specify repos=NULL:
install.packages("/tmp/Rtmp2Rh9Zr/downloaded_packages/haven_1.0.0.tar.gz", repos=NULL)
On my EC2 instance, I ran into the same problems when trying to install packages on RStudio, e.g., car, that involve RAM-intensive compilations. This could be fixed by adding swap space as described here
http://www.exegetic.biz/blog/2015/06/amazon-ec2-adding-swap/

Resources