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.
Hello,I've built a windows binary package from my Mac using the help from this
site: http://win-builder.r-project.org
![Install Package In R From Local File Install Package In R From Local File](/uploads/1/2/6/3/126342612/296922774.jpg)
As expected, I got back the file 'mypackage.zip'. Also, the logs show no
errors.
Now, when I try to install on windows using the GUI 'install package(s)
![Install Install](/uploads/1/2/6/3/126342612/976792669.png)
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 'mypackage/DESCRIPTION', probable reason 'No
such file or directory'
I've attempted to use the solutions from prior similar email threats with
no success. Btw - I've install all the packages dependencies prior to the
above. I'm on R 3.2.0.
Any guidance would be much appreciated.
Thank you.
Axel.
[[alternative HTML version deleted]]
You install a package in R with the function — wait for it — install.packages(). Who could’ve guessed? So, to install the fortunes package, for example, you simply give the name of the package as a string to the install.packages() function.
The fortunes package contains a whole set of humorous and thought-provoking quotes from mailing lists and help sites. You install the package like this:
R may ask you to specify a CRAN mirror. Because everyone in the whole world has to access the same servers, CRAN is mirrored on more than 80 registered servers, often located at universities. Pick one that’s close to your location, and R will connect to that server to download the package files. In RStudio, you can set the mirror by choosing Tools→Options.
Next, R gives you some information on the installation of the package:
It tells you which directory (called a library) the package files are installed in, and it tells you whether the package was installed successfully. Granted, it does so in a rather technical way, but the word successfully tells you everything is okay.
After a while, you can end up with a collection of many packages. If R loaded all of them at the beginning of each session, that would take a lot of memory and time. So, before you can use a package, you have to load it into R by using the library() function.
You load the fortunes package like this:
You don’t have to put single quotation marks around the package name when using library(), but it may be wise to do so.
Now you can use the functions from this package at the command line, like this:
The library is the directory where the packages are installed. Never, ever call a package a library. That’s a mortal sin in the R community. Take a look at the following, and never forget it again:
You can use the fortune() function without arguments to get a random selection of the fortunes available in the package. It’s a nice read.
If you want to unload a package, you’ll have to use some R magic. The detach() function will let you do this, but you have to specify that it’s a package you’re detaching, like this: