How to solve error when installing sf package - r

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

Related

Get error on installing colorspace_2.0-3 from R Studio with R.4.2.1

I have an error when I try to install colorspace (it was ok few days ago) :
install.packages("colorspace")
I have this messsage :
Warning in install.packages : downloaded length 2594858 != reported length 2627626
Warning in install.packages : URL 'http://cran.rstudio.com/bin/windows/contrib/4.2/colorspace_2.0-3.zip': status was 'Transferred a partial file'
Error in download.file(url, destfile, method, mode = "wb", ...) : download from 'http://cran.rstudio.com/bin/windows/contrib/4.2/colorspace_2.0-3.zip' failed
Warning in install.packages : le téléchargement du package ‘colorspace’ a échoué
I have already tried the solution proposed here : 28887446
I notice I can't download the package source "colorspace_2.0-3.tar.gz" from
https://cran.r-project.org/web/packages/colorspace/index.html or from http://cran.rstudio.com/bin/windows/contrib/4.2/. I suppose this is not normal, correct ?
In addition, I can't install Rtools on my professional computer.
Thank you for your help !
Screenshot :
download_error_chrome

Unable to install rmarkdown packages

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

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!

Error while installing ggplot2 package

I am unable to install ggplot2 package. I tried running below code.
install.packages("ggplot2")
also installing the dependencies ‘stringi’, ‘colorspace’, ‘Rcpp’, ‘stringr’, ‘munsell’, ‘plyr’, ‘digest’, ‘reshape2’, ‘scales’
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/stringi_1.0-1.zip'
Content type 'application/zip' length 14265659 bytes (13.6 MB)
downloaded 13.6 MB
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/colorspace_1.2-6.zip'
Content type 'application/zip' length 392857 bytes (383 KB)
downloaded 383 KB
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/Rcpp_0.12.2.zip'
Warning in install.packages :
InternetOpenUrl failed: 'The operation timed out'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/Rcpp_0.12.2.zip'
Warning in install.packages :
download of package ‘Rcpp’ failed
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/stringr_1.0.0.zip'
Content type 'application/zip' length 83159 bytes (81 KB)
downloaded 81 KB
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/munsell_0.4.2.zip'
Content type 'application/zip' length 125762 bytes (122 KB)
downloaded 122 KB
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/plyr_1.8.3.zip'
Warning in install.packages :
InternetOpenUrl failed: 'The operation timed out'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/plyr_1.8.3.zip'
Warning in install.packages :
download of package ‘plyr’ failed
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/digest_0.6.8.zip'
Content type 'application/zip' length 151939 bytes (148 KB)
downloaded 148 KB
trying URL
'http://cran.rstudio.com/bin/windows/contrib/3.2/reshape2_1.4.1.zip'
Warning in install.packages :
InternetOpenUrl failed: 'The operation timed out'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/reshape2_1.4.1.zip'
Warning in install.packages :
download of package ‘reshape2’ failed
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/scales_0.3.0.zip'
Warning in install.packages :
InternetOpenUrl failed: 'The operation timed out'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/scales_0.3.0.zip'
Warning in install.packages :
download of package ‘scales’ failed
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/ggplot2_1.0.1.zip'
Warning in install.packages :
InternetOpenUrl failed: 'The operation timed out'
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot open URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/ggplot2_1.0.1.zip'
Warning in install.packages :
download of package ‘ggplot2’ failed
package ‘stringi’ successfully unpacked and MD5 sums checked
package ‘colorspace’ successfully unpacked and MD5 sums checked
package ‘stringr’ successfully unpacked and MD5 sums checked
package ‘munsell’ successfully unpacked and MD5 sums checked
package ‘digest’ successfully unpacked and MD5 sums checked
I tried installing the plyr package individually but I got the same error
InternetOpenUrl failed: 'The operation timed out'
while installing the dependency package Rcpp and plyr also failed
Try and see if the following syntax works for you:
install.packages("ggplot2", dependencies = TRUE, repos = "http://cran.rstudio.com/")
Mirror names can be changed via "repos".

Unable to install lavaan package

I was trying to install the lavaan package but I encounter the following error message. Do you have any idea how I can resolve this issue?
Thanks,
Joseph
install.packages("lavaan")
Installing package into ‘C:/Users/abc/Documents/R/win-library/3.0’ (as ‘lib’ is unspecified)
trying URL 'http://cran.cnr.Berkeley.edu/bin/windows/contrib/3.0/lavaan_0.5-14.zip'
Content type 'application/zip' length 572076 bytes (558 Kb)
opened URL
downloaded 284 Kb
Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open the connection
In addition: Warning messages:
1: In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 290913 != reported length 572076
2: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
3: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open compressed file 'lavaan/DESCRIPTION', probable reason 'No such file or directory'

Resources