r4photobiology repository

What is a repository?

I have created a small repository for the packages that I have not yet submitted to CRAN. A repository is a set of folders in a server that can be remotely accessed and used as a source of software. The repository used for the photobiology packages follows the CRAN folder structure, so package installation can be done using the normal R commands. This means that dependencies are installed automatically, and that automatic updates are possible. The build most suitable for the current system and R version is also picked automatically if available. It is normally recommended that you do installs and updates on a clean R session (just after starting R or RStudio).

Installing and upgrading packages

Manually

For easy installation and updates of packages, the r4photobiology repository can be added to the list of repositories that R knows about.

Whether you use RStudio or not it is possible to add the r4photobiology repository to the current session as follows:

setRepositories(
graphics = getOption("menu.graphics"),
ind = NULL,
addURLs = c(r4photobiology = "http://www.r4photobiology.info/R"))

which will give you a menu of additional repositories to activate.
If you know the indexes in the menu you can use this code, where ‘1’ and ‘6’ are the entries in the menu in the command above.

setRepositories(
graphics = getOption("menu.graphics"),
ind = c(1, 6),
addURLs = c(r4photobiology = "http://www.r4photobiology.info/R"))

Be careful not to issue this command more than once per R session, otherwise the list of repositories gets corrupted by having two repositories with the same name. The use of c(1, 6) as argument to ind selects two repositories: CRAN and CRANextra. You can enable other default repositories such as the Bioconductor ones by adding the corresponding indexes to this command, or interactively at the R command line interface.

After adding the repository to the session, it will appear in the menu when executing this command:
setRepositories()

and can be enabled and disabled.

In RStudio, after adding the r4photobiology repository as shown above, the photobiology packages can be installed and uninstalled through the normal RStudio menus and dialogues. For example when you type ‘photob’ in the packages field, all the packages with names starting with ‘photob’ will be listed. They can be also installed with:
install.packages(c("photobiologyAll", "photobiologygg"))

and updated with:
update.packages()

The added repository will persist only during the current R session. Adding it permanently requires editing the R configuration file.

Automating the process

Adding a repository by default to R sessions involves creating or editing the .Rprofile file.

The location of the .Rprofile files in the folder structure of the computer determines which sessions it will affect. To affect every session then it should be located in your home directory: Documents in MS-Windows, ~ in Unix, Linux and OS-X. For it to be read only for a certain project, simply locate .Rprofile file in that project’s folder.

You should add the following statement:

utils::setRepositories(graphics = getOption("menu.graphics"),
ind = c(1, 6), addURLs = c(r4photoRepo = "http://www.r4photobiology.info/R"))

The only difference to interactive use is the need to add the name of the package utils followed by ::.

If you would like to have all the Bioconductor repositories always activated you would include the following statement instead of the one given above as the indexes for these repositories are 2, 3, 4, and 5:

utils::setRepositories(graphics = getOption("menu.graphics"),
ind = c(1:6), addURLs = c(r4photoRepo = "http://www.r4photobiology.info/R"))

Leave a Reply

Your email address will not be published. Required fields are marked *