Unable to install lavaan package - r

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'

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

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

Cannot open compressed file when installing R packages

This problem recently came up when I try to install new packages in R 3.2.0. I noticed it when trying to install vegan, but I seem to get the same message for all packages I try to install, including when I try to install manually from a downloaded tar.gz. The entire message I get when I try to install any package is:
utils:::menuInstallPkgs()
also installing the dependency ‘permute’
trying URL 'http://cran.us.r-project.org/bin/windows/contrib/3.2/permute_0.8-4.zip'
Content type 'application/zip' length 501108 bytes (489 KB)
downloaded 489 KB
trying URL 'http://cran.us.r-project.org/bin/windows/contrib/3.2/vegan_2.3-0.zip'
Content type 'application/zip' length 2863206 bytes (2.7 MB)
downloaded 2.7 MB
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) :
write error in extracting from zip file
2: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) :
cannot open compressed file 'permute/DESCRIPTION', probable reason 'No such file or directory'
After looking at previous questions, I tried:
install.packages("vegan", repos="http://cran.us.r-project.org")
but still get the same error. I also tried to reset the repos with:
options(repos=c(CRAN="#CRAN#",
CRANextra="http://www.stats.ox.ac.uk/pub/RWin")
But still get the same error, for any package I try to install.
Thanks for any help.
I got the same error when there was no space left on my computer. I cleared some space and it worked!

cannot install R package

I hit this error when I try to install rJava package in R. Please help
> utils:::menuInstallPkgs()
trying URL 'http://lib.stat.cmu.edu/R/CRAN/bin/windows/contrib/3.1/rJava_0.9-6.zip'
Content type 'text/html; charset=UTF-8' length 3280 bytes
opened URL
downloaded 3280 bytes
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 'rJava/DESCRIPTION', probable reason 'No such file or directory'

Warning while installing package in R

I have been trying to install the ggplot2 package in R and this is the warning I have been getting:
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 1040720 != reported length 1152839
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 'plyr/DESCRIPTION', probable reason 'No such file or directory'
It might be helpful to note that I am using the version 3.1.1. Could you please help me understand what went wrong and how I could resolve this?
Thank you in advance.
From the comments we discovered that somehow your repos option had been set to a bad value.
install.packages has an argument called repos that can be used to specify where to find the package that you'd like to install. If you specify a valid value, it should just work. e.g. you shouldn't get the error if you do this: install.packages("ggplot2", repos="http://cran.us.r-project.org")
If you do not provide a value, it will look at the repos option. See getOption("repos") to see what is set. In your case it was
CRAN CRANextra
"freestatistics.org/cran" "stats.ox.ac.uk/pub/RWin"
neither of which are valid URLs.
You can change the value of the repos option like this
options(repos=c(CRAN="#CRAN#",
CRANextra="http://www.stats.ox.ac.uk/pub/RWin"))

Resources