Description Usage Arguments Details Source See Also Examples
LoadandCite
can install and load R packages as well as automatically
generate a BibTeX file citing the packages.
1 2 3 |
pkgs |
a character vector of R package names. If |
versions |
character vector of package version numbers to install. Only
works if |
Rversion |
a character string specifying a particular R version. If the
version of R currently running differs from |
bibtex |
logical. If |
style |
character string indicating stylistic elements to add to the
citations. Currently supports |
tweak |
logical. Whether to fix some known problems in the citations, especially non-standard format of authors. |
install |
a logical option for whether or not to install the packages.
The default is |
file |
the name of the BibTeX file you want to create. If
|
repos |
character vector specifying which repository to download
packages from. Only relevant if |
lib |
character vector giving the library directories where to install
the packages. Recycled as needed. If |
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
.
Gandrud, Christopher (2013). Automating R Package Citations in Reproducible
Research Documents. SSRN.
This function is partially based on: https://gist.github.com/3710171.
It also builds on code from knitr's 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.
write_bib
, install.packages
, and
library
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.