Installing package from a local zip file in R [duplicate] - r

This question already has an answer here:
Install package without internet: error in install.packages: no such file or directory
(1 answer)
Closed 6 years ago.
I am trying to install a package in R from a local zip file. I have the zip file on a local drive, but when I go to Packages --> Install a package from a local zip file I get the following warning:
> utils:::menuInstallLocal()
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 'cirt/DESCRIPTION', probable reason 'No such file or directory'
What is going on here?
Many thanks in advance,
A

Try :
install.packages(file.choose(), repos = NULL, type="source")
It will allow you to select the desired zip file.

Related

packages installation issues with R 4.1.0

Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) : cannot open the connection
In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) : cannot open compressed file 'shiny/DESCRIPTION', probable reason 'No such file or directory'
Here are the error messages that I am receiving from R 4.1.0 when installing some packages (tidyverse, shiny). I am using R console with windows system. Thank you

Unable to load dplyr in R

I recently upgraded to R 3.5.0 (Windows 10). Following this I have been unable to install dplyr. The error message I get is:
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 17723392 != reported length 17880019
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 'BH/DESCRIPTION', probable reason 'No such file or directory'
I have been able to install other packages and changing the mirror has not helped. I have seen others report this error on but not a consistent fix.
try
install.packages('tidyverse')
then
library(tidyverse)
Tidyverse is a package that includes dplyr and it usally has less problem to get installed.
It also contains ggplot2 so you might not need to load it anymore once you call tydyverse
Have you tried setting dependencies = TRUE, like
install.packages("foo", dependencies=TRUE)
On several occasions this has helped me install packages, that wouldn't get installed otherwise.

Can't install twitteR package in R

I'm trying to install the mentioned package, but in the middle of the process the following message shown and the installation fails.
package ‘rjson’ 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 download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 745472 != reported length 769130
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 'DBI/DESCRIPTION', probable reason 'No such file or directory'
The solution provided here couldn't help, by the way!
You have not shown us "HOW" you tried installing pkg-twitteR but from the fact that it tried to install an additional package, I'm guessing you used dependencies=TRUE in the install.packages-command. (I pretty much always use that parameter, so i'm not criticizing that strategy.) In any case you should now (and always) edit your question to include the exact command or actions you used. You should also include details of your OS and R versions. The missing item appears to be in the "DBI"-package, so I would try:
install.packages("DBI", dependencies=TRUE)
And then retry to install. The installation process sometimes fails when dependencies of dependencies are not met.

sentiment package installation from local zip file issue

I am trying to find a way to install sentiment package in R for performing sentiment analysis.
I searched in all d repositories but it isn't available.I am trying to manually install sentiment_0.2.tar file from local directory but i get this:
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 'sentiment_0.2.tar.gz/DESCRIPTION', probable reason 'No such file or directory'
How do i resolve this problem? any valuable suggestions will be of great help.
Please try:
install.packages(file.choose(), repos = NULL, type="source")
This should allow you to select the file itself and install the package subsequently. Also, please note that the package version may not be compatible with the current R version on your machine.
Thanks!

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