Note in R Cran Check: No Repository Set, So Cyclic Dependency Check Skipped

Two NOTE messages from R CMD check --as-cran

I figured out what the issues were. The function package.skeleton() I used, which automates some of the setup of a new package, uses the following
commands in the automatically generated documentation file mypackage-package.Rd: \packageTitle{}, \packageDescription{}, \packageAuthor{} and \packageMaintainer{}.

The latter commands use build-stage \Sexpr{} expressions. This and the fact that
the file build/partial.rdb was not present lead to the first NOTE message. Note that build/partial.rdb is not generated automatically by package.skeleton().

The reason for the second NOTE message is very similar: The command \packageTitle{} relates to the DESCRIPTION file in order to extract the package title from the field Title:. However, \packageTitle{} could not find the DESCRIPTION file.

As a solution to these problems I did no longer use the commands \packageTitle{}, \packageDescription{}, \packageAuthor{} and \packageMaintainer{}, but wrote the respective texts in the documentation file mypackage-package.Rd directly.

How to select a CRAN mirror in R

You should either get a window with a list of repositories or a text menu with some options. But if that is not appearing, you can always specify the mirror from where to download the packages yourself by using repos parameter. By doing that, R will not ask you anymore about the repository. Example:

install.packages('RMySQL', repos='http://cran.us.r-project.org')

Here you have a list of mirrors for R.

Avoid being asked for CRAN mirror?

If you run help("install.packages"), you can see that the default value for the repository is repos = getOption("repos"). If you follow this trail to help("getOption"), it provides some more insight. Here is what it says for the repos option.

repos:

URLs of the repositories for use by update.packages. Defaults
to c(CRAN="@CRAN@"), a value that causes some utilities to prompt for
a CRAN mirror. To avoid this do set the CRAN mirror, by something like
local({r <- getOption("repos"); r["CRAN"] <- "http://my.local.cran";
options(repos = r)}).

You can see this by going into the 'etc/' subdirectory of your R installation. There is a file there called 'repositories'. While some other repos (e.g., R-Forge) have default URLs, CRAN does not. It shows @CRAN@ as referenced by the help file.

The R documentation advises you that some utilities, such as what you are experiencing at the command line, will prompt you for a mirror, unless the option is explicitly set. The documentation does not indicate an alternative work around.

The reason why there cannot be a function to tell it to use the "most obvious default" is that there is actually no default. So a method such as your hypothetical force() would not be possible.


An edit with a bit more info:

You can use a few helpers from utils to set the repos option. I am not sure if it is easy enough to remember for your criteria, but there is chooseCRANmirror() and getCRANmirrors().

# this should work
chooseCRANmirror(ind = 1)
install.packages("example")

# or this clunky approach
install.packages("example", repos = getCRANmirrors()[1,"URL"])

But honestly at that point you may be better off just remembering repos = https://cloud.r-project.org/.

install.packages errors: Troubleshooting local repo usage

You have the warning unable to access index for repository
because install.packages try to access your custom package in a distant repository ( no local).

To fix this you need to add your local repository to your R-options repos.
You need to add it as url path and not file path. something like file://

Do something like this:

      setRepositories(addURLs=c(lRioTintoIronOre = "file://Q:/Integrated Planning/R"))

To check if all is correct , the following must return TRUE :

    repos <- contrib.url(getOption('repos'))
length(grep("^file:", repos)) > 0L


Related Topics



Leave a reply



Submit