Permalink
Browse files

add ind= to choose{CRAN,BioC}mirror

git-svn-id: https://svn.r-project.org/R/trunk@62399 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information...
1 parent cdfc1e2 commit d6de731435fb98d2af01c541b09397d15beaf1e2 ripley committed Mar 25, 2013
View
@@ -29,6 +29,9 @@
the very rare case that a cumulative sum exceeds
\eqn{2^{53}}{2^53} (necessarily summing more than 4 million
elements).
+
+ \item \code{chooseCRANmirror()} and \code{chooseBioCmirror()} gain
+ an \code{ind} argument (like \code{setRepositories()}).
}
}
@@ -756,7 +756,7 @@ contrib.url <- function(repos, type = getOption("pkgType"))
}
-getCRANmirrors <- function(all=FALSE, local.only=FALSE)
+getCRANmirrors <- function(all = FALSE, local.only = FALSE)
{
m <- NULL
if(!local.only) {
@@ -774,11 +774,13 @@ getCRANmirrors <- function(all=FALSE, local.only=FALSE)
}
-chooseCRANmirror <- function(graphics = getOption("menu.graphics"))
+chooseCRANmirror <- function(graphics = getOption("menu.graphics"), ind = NULL)
{
- if(!interactive()) stop("cannot choose a CRAN mirror non-interactively")
- m <- getCRANmirrors(all=FALSE, local.only=FALSE)
- res <- menu(m[, 1L], graphics, "CRAN mirror")
+ if(is.null(ind) && !interactive())
+ stop("cannot choose a CRAN mirror non-interactively")
+ m <- getCRANmirrors(all = FALSE, local.only = FALSE)
+ res <- if (length(ind)) as.integer(ind)[1L] else
+ menu(m[, 1L], graphics, "CRAN mirror")
if(res > 0L) {
URL <- m[res, "URL"]
repos <- getOption("repos")
@@ -788,9 +790,10 @@ chooseCRANmirror <- function(graphics = getOption("menu.graphics"))
invisible()
}
-chooseBioCmirror <- function(graphics = getOption("menu.graphics"))
+chooseBioCmirror <- function(graphics = getOption("menu.graphics"), ind = NULL)
{
- if(!interactive()) stop("cannot choose a BioC mirror non-interactively")
+ if(is.null(ind) && !interactive())
+ stop("cannot choose a BioC mirror non-interactively")
m <- c("Seattle (USA)"="http://www.bioconductor.org"
, "Bethesda (USA)"="http://watson.nci.nih.gov/bioc_mirror"
, "Dortmund (Germany)"="http://bioconductor.statistik.tu-dortmund.de"
@@ -800,7 +803,8 @@ chooseBioCmirror <- function(graphics = getOption("menu.graphics"))
, "Canberra (Australia)" = "http://mirror.aarnet.edu.au/pub/bioconductor/"
, "Sao Paulo (Brazil)" = "http://bioconductor.fmrp.usp.br/"
)
- res <- menu(names(m), graphics, "BioC mirror")
+ res <- if (length(ind)) as.integer(ind)[1L] else
+ menu(names(m), graphics, "BioC mirror")
if(res > 0L) options("BioC_mirror" = m[res])
invisible()
}
@@ -1,6 +1,6 @@
% File src/library/utils/man/chooseBioCmirror.Rd
% Part of the R package, http://www.R-project.org
-% Copyright 2009-2010 R Core Team
+% Copyright 2009-2013 R Core Team
% Distributed under GPL 2 or later
\name{chooseBioCmirror}
@@ -11,13 +11,15 @@
Interact with the user to choose a Bioconductor mirror.
}
\usage{
-chooseBioCmirror(graphics = getOption("menu.graphics"))
+chooseBioCmirror(graphics = getOption("menu.graphics"), ind = NULL)
}
\arguments{
\item{graphics}{logical. If true, use a graphical list: on Windows or
Mac OS X GUI use a list box, and on a Unix-alike if package
\pkg{tcltk} and an X server are available, use a Tk
widget. Otherwise use a text \code{\link{menu}}.}
+
+ \item{ind}{Optional numeric value giving which entry to select.}
}
\details{
This sets the option \code{"BioC_mirror"}: it needs to be used before
@@ -1,6 +1,6 @@
% File src/library/utils/man/chooseCRANmirror.Rd
% Part of the R package, http://www.R-project.org
-% Copyright 1995-2009 R Core Team
+% Copyright 1995-2013 R Core Team
% Distributed under GPL 2 or later
\name{chooseCRANmirror}
@@ -11,7 +11,7 @@
Interact with the user to choose a CRAN mirror.
}
\usage{
-chooseCRANmirror(graphics = getOption("menu.graphics"))
+chooseCRANmirror(graphics = getOption("menu.graphics"), ind = NULL)
getCRANmirrors(all = FALSE, local.only = FALSE)
}
@@ -21,6 +21,8 @@ getCRANmirrors(all = FALSE, local.only = FALSE)
\pkg{tcltk} and an X server are available, use a Tk
widget. Otherwise use a text \code{\link{menu}}.}
+ \item{ind}{Optional numeric value giving which entry to select.}
+
\item{all}{Logical, get all known mirrors or only the ones flagged as OK.}
\item{local.only}{Logical, try to get most recent list from CRAN or
use file on local disk only.}

0 comments on commit d6de731

Please sign in to comment.