LoadandCite
can install and load R packages as well as automatically
generate a BibTeX file citing the packages.
LoadandCite(pkgs = NULL, versions = NULL, Rversion = NULL, bibtex = TRUE, style = "plain", tweak = TRUE, install = FALSE, file = NULL, repos = NULL, lib = NULL)
pkgs = NULL
then
LoadandCite
only cites the non-base packages in the current session.
It does not load or install any packages.install = TRUE
. The order must match the order of package
names in pkgs
.Rversion
LoadandCite
a warning will be given. This argument is for replication
purposes.TRUE
than a BibTeX formatted citation file
is created. If FALSE
than the citations are returned as plain text.'plain'
, i.e. no special formatting and
'JSS'
to match the BibTeX style for the
Journal of Statistical Software
(see http://www.jstatsoft.org/style).install = FALSE
.file = NULL
then the packages are loaded, but no BibTeX file is
created.install = TRUE
and versions are not
specified. If repos = NULL
, automatically reads user defined
repository (via options
), but defaults to
repos = "http://cran.us.r-project.org"
if repos
is not set.NULL
, defaults to the first
element of .libPaths()
. Only relevant if install = TRUE
.write_bib
. See: Y. Xie. knitr: A
general-purpose package for dynamic report generation in R, 2013. URL
http://CRAN.R-project.org/package=knitr. R package version 1.5. Note
that it does not formally depend on knitr so that knitr can be included in
LoadandCite
so that it is possible to install old versions of that
package.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
.
write_bib
, install.packages
, and
library
# Create vector of package names
## In this example you need to have the packages installed aready.
PackNames <- "repmis"
# Load the packages and create a BibTeX file
LoadandCite(pkgs = PackNames, file = 'PackageCites.bib', style = 'JSS')
## Not run:
# # Install, load, and cite specific package versions
# # dontrun due to CRAN restrictions
# Names <- c("e1071", "gtools")
# Vers <- c("1.6", "2.6.1")
# LoadandCite(pkgs = Names, versions = Vers, install = TRUE,
# file = "PackageCites.bib")
# ## End(Not run)
Run the code above in your browser using DataLab