Learn R Programming

repmis (version 0.2.4)

LoadandCite: Install, load, and cite R packages

Description

LoadandCite can install and load R packages as well as automatically generate a BibTeX file citing the packages.

Usage

LoadandCite(pkgs, versions = NULL, install = FALSE,
    file = "", repos = NULL, lib, ...)

Arguments

pkgs
a character vector of R package names.
versions
character vector of package version numbers. to install. Only works if install = TRUE. The order must match the order of package names in pkgs.
install
a logical option for whether or not to install the packages. The default is install = FALSE.
file
the name of the BibTeX file.
repos
character vector specifying which repository to download packages from. Only relevant if install = TRUE and versions are not specified. If repos = NULL, automatically reads user defined repository (via options
lib
character vector giving the library directories where to install the packages. Recycled as needed. If missing, defaults to the first element of .libPaths(). Only relevant if install = TRUE.
...
other arguments passed to specific methods.

source

This function is partially based on: .

Details

The command can install R packages, load them, and create a BibTeX file that can be used to cite the packages in a LaTeX or similar document. It can be useful to place this command in a knitr code chunk at the beginning of a reproducible research document. Note: the command will overwrite existing files with the same name as file, so it is generally a good idea to create a new BibTeX file with LoadandCite.

See Also

knitr, write_bib, install.packages, and library

Examples

Run this code
# Not Run
# Create vector of package names
## In this example you need to have the packages installed aready.
# PackNames <- c("knitr", "ggplot2")
# Load the packages and create a BibTeX file
# LoadandCite(pkgs = PackNames, file = 'PackageCites.bib')
# Install, load, and cite specific package versions
# Names <- c("e1071", "gtools")
# Vers <- c("1.6", "2.6.1")
# LoadandCite(pkgs = Names, versions = Vers, install = TRUE, file = "PackageCites.bib")

Run the code above in your browser using DataLab