From maechler at stat.math.ethz.ch  Thu Sep 11 11:16:56 2014
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Thu, 11 Sep 2014 11:16:56 +0200
Subject: [Rd] install.packages misleads about package availability?
In-Reply-To: <54109D3B.6080804@fhcrc.org>
References: <54109D3B.6080804@fhcrc.org>
Message-ID: <21521.26760.346920.775217@stat.math.ethz.ch>

>>>>> Martin Morgan <mtmorgan at fhcrc.org>
>>>>>     on Wed, 10 Sep 2014 11:49:31 -0700 writes:

    > In the context of installing a Bioconductor package using our biocLite() 
    > function, install.packages() warns

    >> install.packages("RUVSeq", repos="http://bioconductor.org/packages/2.14/bioc")
    > Installing package into '/home/mtmorgan/R/x86_64-unknown-linux-gnu-library/3.1-2.14'
    > (as 'lib' is unspecified)
    > Warning message:
    > package 'RUVSeq' is not available (for R version 3.1.1 Patched)

    > but really the problem is that the package is not available at the specified 
    > repository (it is available, for the same version of R, in the Bioc devel 
    > repository http://bioconductor.org/packages/3.0/bioc).

    > I can see the value of identifying the R version, and see that mentioning 
    > something about 'specified repositories' would not necessarily be helpful. Also, 
    > since the message is translated and our user base is international, it is 
    > difficult to catch and process by the biocLite() script.

    > Is there a revised wording that could be employed to more accurately convey the 
    > reason for the failure, or is this an opportunity to use the condition system?

    > Index: src/library/utils/R/packages2.R
    > ===================================================================
    > --- src/library/utils/R/packages2.R	(revision 66562)
    > +++ src/library/utils/R/packages2.R	(working copy)
    > @@ -46,12 +46,12 @@
    > p0 <- unique(pkgs)
    > miss <-  !p0 %in% row.names(available)
    > if(sum(miss)) {
    > -	warning(sprintf(ngettext(sum(miss),
    > -				 "package %s is not available (for %s)",
    > -				 "packages %s are not available (for %s)"),
    > -			paste(sQuote(p0[miss]), collapse=", "),
    > -			sub(" *\\(.*","", R.version.string)),
    > -                domain = NA, call. = FALSE)
    > +        txt <- ngettext(sum(miss), "package %s is not available (for %s)",
    > +                        "packages %s are not available (for %s)")
    > +        msg <- simpleWarning(sprintf(txt, paste(sQuote(p0[miss]), collapse=", "),
    > +                                     sub(" *\\(.*","", R.version.string)))
    > +        class(msg) <- c("packageNotAvailable", class(msg))
    > +	 warning(msg)
    > if (sum(miss) == 1L &&
    > !is.na(w <- match(tolower(p0[miss]),
    > tolower(row.names(available))))) {

Yes, I think this would be a fine example and the first one in
"base R" AFAIK of using the condition system by sub classing.

The fact that you cannot check for the warning/error message *text* in
your own tryCatch() or similar  because of internationalization
and hence translation had bitten other people before... and I am
sure is still wrongly used also in package land.. where the bug
never triggers as long as testing is done in the C or an 'en' locale.

How would your  biocLite()  be adapted to use "packageNotAvailable" ?

Martin Maechler, ETH Zurich



[Rd] install.packages misleads about package availability?
Martin Maechler