Error while trying to install R packages - r

I tried to install a package in R by typing:
install.packages("prob")
But got error:
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/prob_0.9-5.zip'
Content type 'application/zip' length 707050 bytes (690 Kb)
opened URL
downloaded 690 Kb
Warning in install.packages :
write error in extracting from zip file
Warning in install.packages :
cannot open compressed file 'gss/DESCRIPTION', probable reason 'No such file or directory'
Error in install.packages : cannot open the connection
How can I resolve it? It only happens with some packages, not all.

The error is suggesting that the package requires another package gss that is not available. That package is not in any of the dependencies but perhaps one of the dependencies requires it in turn. prob's description says:
Version: 0.9-5
Depends: combinat, fAsianOptions, hypergeo, VGAM
When you look at the gss description on CRAN, it says:
Reverse depends: gsscopu, STAR
Reverse imports: fBasics, timeSeq
So I'm guessing that fAsianOptions requires fBasics and that fBasics needs gss. If I'm right, then you should try installing gss first, and then install prob.

Related

R will not install packages

RStudio is not letting me install any new packages. As an example, I attempted to install "rio" today and got the following message:
install.packages("rio")
Installing package into ‘C:/Users/kjl5444/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
dependency ‘openxlsx’ is not available
There is a binary version available but the source version is later:
binary source needs_compilation
rio 0.4.0 0.5.5 FALSE
installing the source package ‘rio’
trying URL 'https://cran.rstudio.com/src/contrib/rio_0.5.5.tar.gz'
Content type 'application/x-gzip' length 390824 bytes (381 KB)
downloaded 381 KB
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Warning in install.packages :
running command '"C:/Program Files/R/R-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\kjl5444\Documents\R\win-library\3.2" C:\Users\kjl5444\AppData\Local\Temp\RtmpaQwlLL/downloaded_packages/rio_0.5.5.tar.gz' had status 1
Warning in install.packages :
installation of package ‘rio’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\kjl5444\AppData\Local\Temp\RtmpaQwlLL\downloaded_packages’
> library(rio)
Error in library(rio) : there is no package called ‘rio’
Any help on deciphering and fixing this error?
While trying to install the rio package in Microsoft windows. I faced an error. In order to resolve that issue, I googled and came to this page.
I know this post is a bit old post but thought to share it for those who face a similar issue in installing this package.
Similar to this post:
Error: "there is no package called ..." and trying to use install.packages to solve it
I could only install rio when I used the command:
install.packages('rio', dependencies = TRUE, repos='http://cran.rstudio.com/')
Perhaps it can help you successfully install the required packages as it ensures that dependencies are also installed along with the required package.

Rcpp installation

I just updated R to 3.4.0 and RStudio to 1.0.143, and I reinstalled some packages. Everything was ok except for Rcpp (and packages which require Rccp), I got this :
> install.packages("Rcpp")
Warning in install.packages :
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES.rds': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.4/PACKAGES.rds': HTTP status was '404 Not Found'
There is a binary version available but the source version is later:
binary source needs_compilation
Rcpp 0.12.10 0.12.11 TRUE
Do you want to install from sources the package which needs compilation?
y/n: y
installing the source package ‘Rcpp’
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
'\\CXXXX0001\Users\RXXXXn'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
'\\CXXXX0001\Users\RXXXXn\R\R-3.4.0' is not recognized as an internal or external command,
operable program or batch file.
Warning in install.packages :
running command '"//CXXXX0001/Users/RXXXn/R/R-3.4.0/bin/x64/R" CMD INSTALL -l "\\CXXXX0001\Users\RXXXXn\R\R-3.4.0\library" C:\Users\RXXX~1\AppData\Local\Temp\RtmpmOL8r0/downloaded_packages/Rcpp_0.12.11.tar.gz' had status 1
Warning in install.packages :
installation of package ‘Rcpp’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\RXXXXn\AppData\Local\Temp\RtmpmOL8r0\downloaded_packages’
I restarted my R session before doing this, so there should be no conflict of loaded packages.
What can I do ?
EDIT after user3293236 comment
I also have a problem with devtools package...
> install.packages("devtools")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/devtools_1.13.1.zip'
Content type 'application/zip' length 440923 bytes (430 KB)
downloaded 430 KB
package ‘devtools’ successfully unpacked and MD5 sums checked
Warning in install.packages :
unable to move temporary installation ‘\\CXXXX0001\Users\RXXXXn\R\R-3.4.0\library\file16401ac3a13\devtools’ to ‘\\CXXXX0001\Users\RXXXXn\R\R-3.4.0\library\devtools’
The downloaded binary packages are in
C:\Users\RXXXXn\AppData\Local\Temp\RtmpmOL8r0\downloaded_packages
> library(devtools)
Error in library(devtools) : aucun package nommé ‘devtools’ n'est trouvé
I encountered the same issue while trying to set up someone else's computer. Brand new R installation (R version 3.4.1) but R was installed in a OneDrive folder. I also thought it was a permissions thing (as #nrussell commented) as the error was the same ... unable to move temporary installation ....
I had no issue installing devtools as normal (or any other packages) and even with Rtools installed Rcpp would not install by install.packages("Rcpp")`. Interestingly,
install.packages("Rcpp", type = 'source')
Did work after some compiling. Strange...
I had similar problem so, I installed a previous Rcpp release and worked.
install_version("Rcpp", version = "1.0.3", repos = "http://cran.us.r-project.org")
What can you do? I would start by reading the error messages.
It clearly showed you that you are offered a different source and binary version. For the former you need tools. That is abundantly documented.
And by tomorrow CRAN will also have a new binary version for you. But with a new release made hours ago, you need to wait a moment. Or make your system capable of installing from source.

Issue in installation of mxnet package in R

mxnet package is not installing in r (on windows 10) when I follow the steps given in its documentation.
install.packages("drat", repos="https://cran.rstudio.com")
drat:::addRepo("dmlc")
install.packages("mxnet")
It gives the following result
Installing package into ‘C:/Users/Ashish/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified) Warning in install.packages : cannot open
URL 'http://dmlc.github.io/drat/bin/windows/contrib/3.3/PACKAGES.gz':
HTTP status was '404 Not Found' Warning in install.packages : cannot
open URL
'http://dmlc.github.io/drat/bin/windows/contrib/3.3/PACKAGES': HTTP
status was '404 Not Found' Warning in install.packages : unable to
access index for repository
http://dmlc.github.io/drat/bin/windows/contrib/3.3: cannot open URL
'http://dmlc.github.io/drat/bin/windows/contrib/3.3/PACKAGES' Package
which is only available in source form, and may need compilation of
C/C++/Fortran: ‘mxnet’ Do you want to attempt to install these from
sources? y/n: y installing the source package ‘mxnet’
trying URL 'http://dmlc.github.io/drat/src/contrib/mxnet_0.5.tar.gz'
Warning in install.packages : cannot open URL
'http://dmlc.github.io/drat/src/contrib/mxnet_0.5.tar.gz': HTTP status
was '404 Not Found' Error in download.file(url, destfile, method, mode
= "wb", ...) : cannot open URL 'http://dmlc.github.io/drat/src/contrib/mxnet_0.5.tar.gz' Warning in
install.packages : download of package ‘mxnet’ failed
Kindly help me resolve this issue. I'm using R version 3.3.0. Is there any other way of installing it in R?
I was able to install it successfully by first downloading its zip file from the following link
https://github.com/dmlc/drat/tree/gh-pages/bin/windows/contrib/3.2
and then installing it using RStudio.
I hope this answer will help anyone else facing the same problem.
I had the same issue and was able to resolve it by following the instructions on this page and choosing the correct OS, Language and CPU/GPU options:
http://mxnet.io/get_started/install.html
The only thing that worked for me was to download the mxnet.zip file to a folder, (set it as working directory) and type:
install.packages("mxnet.zip", repos=NULL, type="win.binary")
You can try using different repo in repos.
Otherwise you can download the drat package along with dependencies and install manually.
Check if these URLs are accessible from your machine or not.
Following links will be helpful for you:
http://mxnet-bing.readthedocs.io/en/latest/build.html#r-package-installation
https://github.com/dmlc/mxnet/issues/1085
The more up-to-date Installation Guide is currently located here:
http://mxnet.io/get_started/setup.html#installing-mxnet
I found the paragraph about the installation of the R-package on Windows to be very well written.
By the way, the install.packages("mxnet") command installs a very long tool chain, so it might happen that a package is currently not indexed correctly in the dmlc-repo (i.e. because it was just updated to a newer version on CRAN): Error: package <pkgname> is not available for R version 3.3.1 So you might want to install the "offending" package from the CRAN (or download the sourcecode and use something like install.packages(file.choose(), repos = NULL, type = "source")), then continue with another call to install.packages("mxnet").
try these commands to install mxnet package:--
cran <- getOption("repos")
cran["dmlc"] <- "https://s3-us-west-2.amazonaws.com/apache-mxnet/R/CRAN/"
options(repos = cran)
install.packages("mxnet")

install xlsx and xlsxjars in R 3.2.0

Since today I am using the R Version 3.2.0 for statistical analysis. Today I try to install the packages "xlsx" and "xlsxjars" for my new installation but it didn't work. Every time I try to install the packages (install.packages("xlsx")) I get the following error message:
Warning in install.packages :
downloaded length 9351168 != reported length 9485172
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/xlsx_0.5.7.zip'
Content type 'application/zip' length 400857 bytes (391 KB)
downloaded 391 KB
Warning in install.packages :
error 1 in extracting from zip file
Warning in install.packages :
cannot open compressed file 'xlsxjars/DESCRIPTION', probable reason 'No such file or directory'
Error in install.packages : cannot open the Connection`
The problem only take place when I try to install the xls-packages. Other packages can be installed smoothly without any problems.
I hope there is anyone out there who had already installed the aforesaid packages in R Version 3.2.0 and can give me a short advice how to install the packages in the new R Version?
First,
setInternet2(use=TRUE)
Then install necessary packages individually:
install.packages('rJava')
install.packages('xlsxjars')
install.packages('xlsx')

Installing lattice in R: "Error : Invalid DESCRIPTION file"

I'm using R 3.0.2 and am trying to install the lattice package, like so:
install.packages("lattice")
This leads to the following error:
Error : Invalid DESCRIPTION file
Invalid Priority field. Packages with priorities 'base' or 'recommended' or 'defunct-base' must already be known to R.
How can I fix it?
Since the DESCRIPTION just seems to contain meta-info, I do not see why this should preclude me from installing the lattice package.
Update:
I have lattice installed, but need a newer version due to some dependencies. Using update.packages() for lattice returns the same error as above. I wonder if it is possible that the newer lattice versions are not compatible with the new R version?
Seeing BondedDust referring to DESCRIPTION I started investigating it, and it seems the new package has a Priority field in the DESCRIPTION file, but that the old version of the lattice DESCRIPTION file does not. Why should this matter?
me#tang:~/test_lattice$ grep Priority /home/endrebak/local/anaconda/lib64/R/library/lattice/DESCRIPTION
me#tang:~/test_lattice$ grep Priority lattice/DESCRIPTION #New version
Priority: recommended
I've tried updating the old DESCRIPTION file with a Priority: recommended line and reloading R, but still
>rownames(installed.packages(priority="recommended"))
NULL
#rownames(installed.packages(priority="base")) works fine, however.
Full error message below:
trying URL 'http://cran.uib.no/src/contrib/lattice_0.20-29.tar.gz'
Content type 'application/x-gzip' length 347091 bytes (338 Kb)
* installing *source* package ‘lattice’ ...
** package ‘lattice’ successfully unpacked and MD5 sums checked
Error : Invalid DESCRIPTION file
Invalid Priority field.
Packages with priorities 'base' or 'recommended' or 'defunct-base' must
already be known to R.
See the information on DESCRIPTION files in section 'Creating R
packages' of the 'Writing R Extensions' manual.
ERROR: installing package DESCRIPTION failed for package ‘lattice’
* removing ‘/home/me/local/anaconda/lib64/R/library/lattice’
* restoring previous ‘/home/me/local/anaconda/lib64/R/library/lattice’
The downloaded source packages are in
‘/tmp/Rtmptpj1ff/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("lattice") :
installation of package ‘lattice’ had non-zero exit status
I fixed this error by upgrading to R 3.2.
I solved this by just deleting the "Priority: recommended" line in the DESCRIPTION file

Resources