Installation Error When Installing Package from R Forge - r

I am trying to update zoo from R Forge.
install.packages("zoo", repo = "http://r-forge.r-project.org")
But I get the following error
Installing package(s) into ‘C:/REVOLU~1/R-COMM~1.3/R-212~1.2/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
cannot open: HTTP status was '404 Not Found'
Warning in install.packages :
cannot open: HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository http://r-forge.r-project.org/bin/windows/contrib/2.12
Warning in install.packages :
package ‘zoo’ is not available
I am using Revolution R Community version 4.3 (64-bit).
install.packages("zoo")
Installs a slightly dated version of zoo

To clarify #DWin's and Gabor's answers slightly more:
You are running into trouble because R-forge only builds binaries for the current (2.14 right now) and development ("2.15", but Brian Ripley will probably get mad if you refer to it that way) versions of packages. In this situation you have the following options:
Upgrade R to the current version (the best idea).
If you have good reasons you can't do that (you don't have administrative rights, you are running a critical analysis that depends on a previous version of R, you need to use Revolution R because of its extensions etc.), then you can try one of the following:
(as suggested by #jthetzel's comment above) follow the links to the binary version of the package, download the binary file (zip in the case of Windows), and try installing from the local copy (with repos=NULL, or from the appropriate menu entry). This will not work if the package depends, implicitly or explicitly, on features in the latest version of R.
try to install the source version of the package: install.packages("thispkg",repos="http://r-forge.r-project.org",type="source"). This will only work if (1) you have the tools for compiling packages from source installed (see the R manual, or (for Windows) the R for Windows FAQ, google for "Rtools", etc., or (for MacOS) the R for MacOS FAQ) or (2) the package contains only R code, not compiled C/FORTRAN code (not true in the case of the zoo package, I think).
download the source package, unpack it, modify the DESCRIPTION file so that the maintainer e-mail is your own, rebuild the source package, and upload it to the CRAN win-builder service. (If you don't modify the DESCRIPTION file then you won't be informed that the package has been built and where to download it -- you'll just annoy and confuse the maintainer of the package, who will receive the e-mail.) (This only works for Windows.)
Some of the resistance you've been getting is directed less at you than at Revolution R. There's nothing wrong (I don't think) with their making money from R, but when providing support for Revolution R adds to the workload of the R community (ordinarily we would just say "upgrade to the latest version of R" and be done with it), people get a little grumpy.

This is the weekend, .... a typical time for site maintenance. A 404 message could be telling you to either wait a few hours or use a different mirror. In this case using a browser shows that the link really does not exist but its stem does and has code only for R versions 2.14 and 2.15.
You have not given enough information to determine why "version 4.3" is not accessing a current version of "zoo" but it would seem more appropriate to contact the Revolution R people or a support group dedicated to that version than post a message on a volunteer website where they seem to have no regular representative. I'm guessing that your "version 4.3" is based on R 2.12.x and that you would get failure if you actually did find a current version. You should be providing sessionInfo() rahter than the RevoR version number. The RevoR product has a Support Forum at http://forums.revolutionanalytics.com/ . My effort to determine what version they are currently shipping are frustrated by their insistence on having every query go through their personal information gathering protocol. I was unable to find online technical specs for their currently available version of "Community version".
EDIT: It appears you have already been discussing this with Gabor. He is an undisputed authority on the behavior of "zoo". You should not be looking elsewhere for advice.

Related

Install R packages outside R

So the thing is my IT department is scared of R and therefore only allows us to use it on a laptop that can't go online. Therefore they are the ones to install packages on it.
But due to covid I'm at home discovering they didn't install the requested packages. So I'm looking to see if there is a way to download these packages on a laptop with internet access, add them to an USB and then install them from the USB in R?
Quite easy, just download the package from the CRAN site e.g. https://cran.r-project.org/web/packages/imputeTS/
You can either download the "Package source" or the "Binaries" (must be your operating system.
If you are using R Studio, there is then even a menu item for installing the package - just select the file you downloaded and here you go.
If you are not using R Studio, just provide the path to your downloaded archive in the install.packages command.
The only problem is, you also need all the dependencies ...;)
So you ideally already have them and just one package is somehow missing - otherwise this can get quite time consuming to download all the dependencies - because the dependencies itself also usually have dependencies themselves...
In this case the miniCRAN solution Roland linked in the comments might be an idea. ( Offline installation of a list of packages: getting dependencies in order ) But didn't try the miniCRAN myself yet - would be interested how good this actually works.

Problems with installation R packages

I'm a Windows user. A few weeks ago I installed R and Rstudio along with many packages. Today there was a message that new packages were not installed.
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
I reinstalled R but this did not solve the problem.
Warning in install.packages :
InternetOpenUrl failed: 'Can not connect to server'
This is something that pops up in R and RStudio only once in a while. RStudio changes quite a few settings, and the option "repos" is one of them. On Windows, the following is added
EDIT: It's not RStudio adding this extra repository. The repository is kindly provided by Dr. Brian Ripley for packages that for some reason can't be made available on CRAN (license, not building out of the box, requiring additional software, ...). This is called "CRANextra" in the settings:
> getOption("repos")
CRAN CRANextra
"https://cran.rstudio.com/" "http://www.stats.ox.ac.uk/pub/RWin"
attr(,"RStudio")
[1] TRUE
So RStudio tries to access a specific repository when run on Windows, but that repository has had some connection issues in the past; it isn't always reachable, and when it's not, the warnings you report are issued.
You can get this warning to stop by resetting this option:
options(repos = "https://cran.rstudio.com") # or a repo of your choice.
Which allows you to install packages without the warning:
> install.packages("fortunes")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/fortunes_1.5-4.zip'
Content type 'application/zip' length 202721 bytes (197 KB)
downloaded 197 KB
package ‘fortunes’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Joris\AppData\Local\Temp\Rtmpu0febg\downloaded_packages
Even when this warning is displayed, packages still get installed from the rstudio CRAN mirror. The warning is reported as a bug, and RStudio has promised to tackle it soon.
EDIT: More information on the CRANextra repository in R FAQ (last paragraph):
Some CRAN packages that do not build out of the box on Windows,
require additional software, or are shipping third party libraries for
Windows cannot be made available on CRAN in form of a Windows binary
packages. Nevertheless, some of these packages are available at the
“CRAN extras” repository at https://www.stats.ox.ac.uk/pub/RWin/
kindly provided by Brian D. Ripley. Note that this repository is a
default repository for recent versions of R for Windows.
In the mean while R Studio fixes the bug, a temporal solution for not having to especifie the CRAN repository every time we start an R session, is to edit your "Rprofile.site" file and add this line
options(repos = getOption("repos")["CRAN"])
That way every time an R session is started the CRANextra repository ("http://www.stats.ox.ac.uk/pub/RWin") is removed automatically. Just remember to delete or comment with # this line after the bug is solved.
I was facing similar issue and the fix that worked for me is that, in RStudio I've opened tools -> Global Options -> Packages -> Primary CRAN Repository -> Set Global.
Also make sure you're not using installed.packages this happens to a lot of people because of RStudio typing suggestions.
You need to use install.packages("<package_name>")

Changes in install.packages() from R 3.1.2 to R 3.2.1

I am working on a Windows 7 machine without internet access. As yet, I got around the missing internet connection by creating a local copy of the binary CRAN repository in //server/x/bin/windows/contrib/3.1, then running write_PACKAGES("//server/x/bin/windows/contrib/3.1") and finally setting r["CRAN"]="file:////server/x";r["CRANextra"]=r["CRAN"]; in C:/Program Files/R/R-3.1.2/etc/Rprofile.site.
But this does not work any longer since R 3.2.1. The path in the error message of install.packages indicates that R is looking for the source package:
Cannot open compressed file '//server/x/src/contrib/PACKAGES'
I have thought that R on Windows only looks for binary packages!
Looking at a diff between install.packages for 3.1.2 and 3.2.1, I can see quite a few changes. However, the source code for the function has 500+ lines which makes it hard for me to see where specifically the problem lies.
I have tried to set
options(install.packages.check.source="no")
and to explicitly add type="win.binary" to install.packages - both without success.
It is also interesting that
contrib.url(options("repos")$repos["CRAN"],type="win.binary")
gives the correct path file:////server/x/bin/windows/contrib/3.2 but somehow this is not used by install.packages(...,type="win.binary")...
So my question is whether you guys have experienced similar problems?
If no, I would be grateful for any pointers to mistakes I could have made.
I have found the problem.
The R 3.2.1 NEWS section (https://cran.r-project.org/src/base/NEWS) says
The default for option pkgType on platforms using binary packages is now "both", so source packages will be tried if binary versions
are not available or not up to date.
The problem is that RStudio does not directly call install.packages but via a few other functions such as .rs.callAs. In one of these functions, available.packages() gets called without any arguments. So it determines the argument type via getOption("pkgType"). But since R 3.2.1 this is now "both" and not "win.binary" as in R 3.1.2.
A quick workaround for the problem is thus to add
options(pkgType="win.binary")
to the yourRinstallpath/etc/Rprofile.site

How do you import an R module to a computer with no internet?

I'm working on a mac computer that has restricted-use data and cannot be connected to the internet. I need an R-module on the computer called rgexf. When I try to install it on R following the instructions here:
> install.packages('[where the zip file is]/rgexf_0.12.03.tar.gz', repos = NULL)
I get this error:
Installing package(s) into '/Users/samfinegold/Library/R/2.15/library' (as 'lib' is unspecified)
Warning: unable to access index for repository NULL/bin/macosx/leopard/contrib/2.15
Warning message: package '/Users/samfinegold/Desktop/rgexf_0.13.01.tar.gz' is not available (for R version 2.15.3)
I don't understand why the package wouldn't be available for the most recent version of R though.
You have specified a source package (identified by the "tar.gz" extension) but not told install.packages to use type ="source". You are also asking for the most recent version of the file which might be mated to version 3.0.0 for R.Its DESCRIPTION file says it does require compilation so you either need properly set-up tools for building source packages (if you want to install from source), or you need an appropriate binary version of the package. Whether there is an earlier version that can be mated to R 2.15.3 is an open question.
If you want to compile packages from source, you must have the correct XCode for the version of OSX that is on your machine. And you may need to get additional development tools from the ATT.research website. And if you have a more recent version of Xcode (higher than 3.x I think), don't forget to install the Command Line Tools package either from the Apple Developer Store or using the drop-down menu in a running installation of Xcode.
There is a MacOS binary at CRAN. Given your difficulties with source installation I would try to get a copy of that on a USB stick and retry with a binary distribution. (You do not need to use type="mac.binary" since that is the default for that parameter to install.packages.
Have you checked the permissions on the computer? The first warning message looks like it could be a root/admin vs. user issue for accessing the file. The other possibility since you have a NULL in the warning message is that you've entered the directory wrong (try without the '/' to lead perhaps).

Did the subdirectory structure of package repositories change as of R 2.15.2?

Kind of embarrassing / a no-go, but since it hasn't been that long that I've moved from "pure user" to "beginner-developer", I've never actually read the CHANGELOG when a new R version came out - well until today (and I have the feeling I should make this a habbit) ;-)
Yet I'm not sure if the supposed change actually occurred since I couldn't find anything about it at a first glimpse at the CHANGELOG of R R 2.15.2:
Actual question
Is it possible that the (subdirectory) structure of package repositories changed from
./bin/windows/contrib/2.xx/
to
./src/contrib/2.xx/ or even ./src/contrib?
Or at least that the PACKAGES file now needs to live here: ./src/contrib/PACKAGES?
Background info
Up to version 2.15.1, the following path worked to install packages from my local package repository:
path.repos <- "L:/R/packages"
repos <- file.path("file://", path.repos)
Function contrib.url would take repos and expand it to the right subdirectory:
> contrib.url(repos)
[1] "file:///L:/R/packages/bin/windows/contrib/2.15"
But when I try to run install.packages(), I get the following error for R 2.15.2:
> install.packages("mypkg",
+ lib=file.path(R.home(), "library"),
+ repos=repos,
+ type="win.binary"
+ )
Error in read.dcf(file = tmpf) : cannot open the connection
In addition: Warning message:
In read.dcf(file = tmpf) :
cannot open compressed file 'L:/R/packages/src/contrib/PACKAGES', probable reason 'No such file or directory'
>
When I do the same with R 2.15.1, everything works smoothly.
Due dilligence
There are some references with respect to repositories in the CHANGELOG, but the only section I found that gives me some evidence that the supposed change occurred is this:
PACKAGE INSTALLATION
For a Windows or Mac OS X binary package install, install.packages() will check if a source package is available on the same repositories, and report if it is a later version or there is a source package but no binary package available.
Just had a look at the official documentation again and got the idea that maybe arg type is not passed along to contrib.url() correctly as it seems to me install.package() is looking at the place for type="source" packages?
This particular bug isn't the same as mine.
This issue relates to checks install.packages() now runs before installing. As Rappster said, it tries to find a source package to compare the binary version with:
For a Windows or Mac OS X binary package install, install.packages() will check if a source package is available on the same repositories, and report if it is a later version or there is a source package but no binary package available.
So a simple way of squashing this message is creating the R/src/contrib directory and running tools::write_PACKAGES() in that directory to create (an empty) PACKAGES file.
And of course, the reason you aren't getting this message in 2.15.1 is that it doesn't do the checking (see R NEWS quote above) that 2.15.2 performs.
I have submitted a bug report of my issues. No news yet. May post it to the R mailing list as well.

Resources