Unable to install rmarkdown packages - r

Here's what I got...
** Installing R Package Dependencies for R Markdown: 'rmarkdown', 'stringi'
[1/2] Installing rmarkdown...
trying URL 'http://cran.rstudio.com/src/contrib/rmarkdown_2.9.tar.gz'
Content type 'application/x-gzip' length 3246617 bytes (3.1 MB)
================================================[2/2] Installing stringi...
downloaded 3.0 MB
Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'http://cran.rstudio.com/src/contrib/rmarkdown_2.9.tar.gz' failed
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 3152276 != reported length 3246617
2: In download.file(url, destfile, method, mode = "wb", ...) :
URL 'http://cran.rstudio.com/src/contrib/rmarkdown_2.9.tar.gz': Timeout of 60 seconds was reached
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘rmarkdown’ failed
trying URL 'http://cran.rstudio.com/bin/macosx/contrib/4.1/stringi_1.7.3.tgz'
Content type 'application/x-gzip' length 14636855 bytes (14.0 MB)
=========
downloaded 2.7 MB
Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'http://cran.rstudio.com/bin/macosx/contrib/4.1/stringi_1.7.3.tgz' failed
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 2835937 != reported length 14636855
2: In download.file(url, destfile, method, mode = "wb", ...) :
URL 'http://cran.rstudio.com/bin/macosx/contrib/4.1/stringi_1.7.3.tgz': Timeout of 60 seconds was reached
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘stringi’ failed

You can stop all of that output after the first mention of Timeout of 60 seconds was reached. It appears you are experiencing network glitches, and R is not adapting to them well.
Three suggestions:
increase R's timeout, per #Phil's answer;
keep trying with install.packages(..) until it finally works, hoping luck will eventually smile on you; or
download externally, verify the files downloaded, then install manually.
Assuming the third, then using firefox/chrome/safari (or whatever you prefer), download the URLs present in your R console manually to a directory. I'll assume the local directory, but you can save them to where-ever you prefer.
AP <- available.packages()
AP[AP[,1] %in% c("rmarkdown", "stringi"),c("Package", "Version", "MD5sum", "Repository")]
# Package Version MD5sum Repository
# rmarkdown "rmarkdown" "2.9" "acd82da6a09f8e6564595dfa9039e032" "https://cran.rstudio.com/src/contrib"
# stringi "stringi" "1.7.3" "94c37221840cd9f5b7545c585d0c6b07" "https://cran.rstudio.com/src/contrib"
system("md5sum rmarkdown_2.9.tar.gz")
# acd82da6a09f8e6564595dfa9039e032 *rmarkdown_2.9.tar.gz
# [1] 0
(and repeat for stringi).
Assuming that the checksums match, then you can do
install.packages(c("rmarkdown_2.9.tar.gz", "stringi_1.7.3.tgz"), repos = NULL)
to install the downloaded files.

The error is that the timeout of 60 seconds is reached (i.e. it's taking too long to download). A workaround is to increase the timeout time:
options(timeout=120)
Or maybe longer if you need it

Related

How to solve error when installing sf package

I am using a newer Mac laptop with a M1 chip and R version 4.2.2 and get the following error when trying to install sf in RStudio. How can I fix this?
> install.packages("sf")
trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.2/sf_1.0-9.tgz'
Content type 'application/x-gzip' length 89952912 bytes (85.8 MB)
====================================
downloaded 62.6 MB
Warning in install.packages :
downloaded length 65639971 != reported length 89952912
Warning in install.packages :
URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.2/sf_1.0-9.tgz': Timeout of 60 seconds was reached
Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.2/sf_1.0-9.tgz' failed
Warning in install.packages :
download of package ‘sf’ failed
If I try installing it in base R, I get:
Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'https://mirrors.nics.utk.edu/cran/bin/macosx/big-sur-arm64/contrib/4.2/sf_1.0-9.tgz' failed
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 57524224 != reported length 89952912
2: In download.file(url, destfile, method, mode = "wb", ...) :
URL 'https://mirrors.nics.utk.edu/cran/bin/macosx/big-sur-arm64/contrib/4.2/sf_1.0-9.tgz': Timeout of 60 seconds was reached
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘sf’ failed

Installing stringi repeatedly fails

I am trying to install likert, which requires stringi.
install.package("likert") fails to install stringi.
install.package("stringi") from CRAN fails as well:
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.2/stringi_1.7.6.tgz'
Content type 'application/x-gzip' length 14390020 bytes (13.7 MB)
==================================
downloaded 9.3 MB
Warning in install.packages :
downloaded length 9800943 != reported length 14390020
Warning in install.packages :
URL 'https://cran.rstudio.com/bin/macosx/contrib/4.2/stringi_1.7.6.tgz': Timeout of 60 seconds was reached
Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'https://cran.rstudio.com/bin/macosx/contrib/4.2/stringi_1.7.6.tgz' failed
Warning in install.packages :
download of package ‘stringi’ failed
I downloaded the package from https://cran.r-project.org/web/packages/stringi/index.html and tried installing:
install.packages("~/Desktop/downloads/stringi_1.7.6.tgz", repos = NULL, type = .Platform$pkgType)
But this also failed:
Error: package or namespace load failed for ‘stringi’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/stringi/libs/stringi.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.2/Resources/library/stringi/libs/stringi.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libR.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.2/Resources/library/stringi/libs/stringi.so
Reason: image not found
What is going on? I have the latest version of R and R Studio for Mac.
I figured it out. The problem was the timeout. It took too long to load.
I fixed it by changing the timeout from 60seconds to a larger number:
getOption('timeout')
[1] 60
options(timeout=300)

package ‘GEOquery’ is not available (for R version 3.6.1)

In my windows 10 enviornment with latest version of R and RStudio, I am not able to download many of R packages like I mentioned, similarly R bioconductor package I am not being able to download,So whats the problem?
install.packages('GEOquery')
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/samer/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘GEOquery’ is not available (for R version 3.6.1)
install.packages('bioconductor')
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/samer/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘bioconductor’ is not available (for R version 3.6.1)
Update:
I downloaded and installed Rtools from the direct link instead from within the RStudio Environment.
Then I have following issues now.
BiocManager::install("GEOquery")
Bioconductor version 3.9 (BiocManager 1.30.7), R 3.6.1 (2019-07-05)
Installing package(s) 'BiocVersion', 'GEOquery'
also installing the dependencies ‘rlang’, ‘tidyselect’, ‘plogr’, ‘ellipsis’, ‘purrr’, ‘vctrs’, ‘lifecycle’, ‘Biobase’, ‘readr’, ‘xml2’, ‘dplyr’, ‘tidyr’, ‘limma’
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/rlang_0.4.0.zip'
Content type 'application/zip' length 1090422 bytes (1.0 MB)
downloaded 1.0 MB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/tidyselect_0.2.5.zip'
Content type 'application/zip' length 627063 bytes (612 KB)
downloaded 612 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/plogr_0.2.0.zip'
Content type 'application/zip' length 18873 bytes (18 KB)
downloaded 18 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/ellipsis_0.3.0.zip'
Content type 'application/zip' length 44553 bytes (43 KB)
downloaded 43 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/purrr_0.3.2.zip'
Content type 'application/zip' length 421098 bytes (411 KB)
downloaded 411 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/vctrs_0.2.0.zip'
Content type 'application/zip' length 828462 bytes (809 KB)
downloaded 809 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/lifecycle_0.1.0.zip'
Content type 'application/zip' length 84709 bytes (82 KB)
downloaded 82 KB
trying URL 'https://bioconductor.org/packages/3.9/bioc/bin/windows/contrib/3.6/Biobase_2.44.0.zip'
Content type 'application/zip' length 2421976 bytes (2.3 MB)
downloaded 2.3 MB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/readr_1.3.1.zip'
Content type 'application/zip' length 1589745 bytes (1.5 MB)
downloaded 1.5 MB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/xml2_1.2.2.zip'
Content type 'application/zip' length 3503035 bytes (3.3 MB)
downloaded 3.3 MB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/dplyr_0.8.3.zip'
Content type 'application/zip' length 3265027 bytes (3.1 MB)
downloaded 764 KB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/tidyr_1.0.0.zip'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/tidyr_1.0.0.zip'
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 782336 != reported length 3265027
2: In download.file(url, destfile, method, mode = "wb", ...) :
InternetOpenUrl failed: 'The server returned an invalid or unrecognized response'
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘tidyr’ failed
trying URL 'https://bioconductor.org/packages/3.9/bioc/bin/windows/contrib/3.6/limma_3.40.6.zip'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://bioconductor.org/packages/3.9/bioc/bin/windows/contrib/3.6/limma_3.40.6.zip'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
InternetOpenUrl failed: 'The operation timed out'
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘limma’ failed
trying URL 'https://bioconductor.org/packages/3.9/bioc/bin/windows/contrib/3.6/BiocVersion_3.9.0.zip'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://bioconductor.org/packages/3.9/bioc/bin/windows/contrib/3.6/BiocVersion_3.9.0.zip'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
InternetOpenUrl failed: 'The operation timed out'
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘BiocVersion’ failed
trying URL 'https://bioconductor.org/packages/3.9/bioc/bin/windows/contrib/3.6/GEOquery_2.52.0.zip'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'https://bioconductor.org/packages/3.9/bioc/bin/windows/contrib/3.6/GEOquery_2.52.0.zip'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
InternetOpenUrl failed: 'The operation timed out'
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘GEOquery’ failed
package ‘rlang’ successfully unpacked and MD5 sums checked
package ‘tidyselect’ successfully unpacked and MD5 sums checked
package ‘plogr’ successfully unpacked and MD5 sums checked
package ‘ellipsis’ successfully unpacked and MD5 sums checked
package ‘purrr’ successfully unpacked and MD5 sums checked
package ‘vctrs’ successfully unpacked and MD5 sums checked
package ‘lifecycle’ successfully unpacked and MD5 sums checked
package ‘Biobase’ successfully unpacked and MD5 sums checked
package ‘readr’ successfully unpacked and MD5 sums checked
package ‘xml2’ successfully unpacked and MD5 sums checked
Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open the connection
In addition: Warning messages:
1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
2: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open compressed file 'dplyr/DESCRIPTION', probable reason 'No such file or directory'
To install bioconductor packages is not like normal R packages. To do so, follow the steps here:
Example Code:
source("https://bioconductor.org/biocLite.R")
BiocInstaller::biocLite(c("GEOquery"))
To install Rtools get the latest download from here and install it, then re-try the code.
Edit:
Apparently there are updated installation practices, so the correct code should be:
BiocManager::install("GEOquery")

Installing geoR on Ubuntu 16.04

I'm having issues installing the geoR package on ubuntu 16.04, when I run
>install.packages('geoR', dependencies = TRUE)
I get the following error message
/usr/lib/R/etc/Makeconf:141: recipe for target 'RFoptions.o' failed
make: *** [RFoptions.o] Error 1
ERROR: compilation failed for package ‘RandomFieldsUtils’
* removing ‘/home/luca/R/x86_64-pc-linux-gnu-library/3.2/RandomFieldsUtils’
The downloaded source packages are in
‘/tmp/Rtmph5zmhR/downloaded_packages’
Warning message:
In install.packages("RandomFieldsUtils") :
installation of package ‘RandomFieldsUtils’ had non-zero exit status
>
> install.packages('geoR', dependencites = TRUE)
Installing package into ‘/home/luca/R/x86_64-pc-linux-gnu-library/3.2’
(as ‘lib’ is unspecified)
also installing the dependencies ‘RandomFieldsUtils’, ‘RandomFields’
Error in download.file(url, destfile, method, mode = "wb", ...) :
unused argument (dependencites = TRUE)
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘RandomFieldsUtils’ failed
Error in download.file(url, destfile, method, mode = "wb", ...) :
unused argument (dependencites = TRUE)
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘RandomFields’ failed
Error in download.file(url, destfile, method, mode = "wb", ...) :
unused argument (dependencites = TRUE)
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘geoR’ failed
It seems to me that the issue is with the RandomFieldsUtils package, and also when I try to run
>install.packages('RandomFieldsUtils')
I get the same error
/usr/lib/R/etc/Makeconf:141: recipe for target 'RFoptions.o' failed
make: *** [RFoptions.o] Error 1
ERROR: compilation failed for package ‘RandomFieldsUtils’
* removing ‘/home/luca/R/x86_64-pc-linux-gnu-library/3.2/RandomFieldsUtils’
The downloaded source packages are in
‘/tmp/Rtmph5zmhR/downloaded_packages’
Warning message:
In install.packages("RandomFieldsUtils") :
installation of package ‘RandomFieldsUtils’ had non-zero exit status
I'm pretty new to R and tried this both in R Studio and in the Ubuntu console, got the same message twice.
Any idea how to fix it?
thanks in advance
After playing around a bit, I managed by downloading the second-to-latest version of RandomFieldsUtils (i.e. 0.3.16 instead of 0.3.20) directly from the contributor's website and installing it from the package.
Posting this answer to myself in case it can help anybody!

Cannot install package Rmysql

When I try the following command
install.packages('RMySQL',type='source')
I got an error as below
Installing into ‘C:/Users/Thanushiya/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://ftp.iitm.ac.in/cran/src/contrib/RMySQL_0.10.6.tar.gz'
Content type 'application/x-gzip' length 52407 bytes (51 KB)
downloaded 36 KB
Error in untar2(tarfile, files, list, exdir, restore_times) :
incomplete block on file
The downloaded source packages are in
‘C:\Users\Thanushiya\AppData\Local\Temp\RtmpSMF6pv\downloaded_packages’
Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 36864 != reported length 52407
2: running command '"C:/PROGRA~1/R/R-32~1.2/bin/i386/R" CMD INSTALL -l "C:\Users\Thanushiya\Documents\R\win-library\3.2" C:\Users\THANUS~1\AppData\Local\Temp\RtmpSMF6pv/downloaded_packages/RMySQL_0.10.6.tar.gz' had status 1
3: In install.packages("RMySQL", type = "source") :
installation of package ‘RMySQL’ had non-zero exit status

Resources