forked from Pakillo/grateful
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' Cite R packages used in a project | ||
#' | ||
#' This is a wrapper function. | ||
#' | ||
#' @param all.pkg Logical. Include all packages used in scripts within the project/folder (the default), or only packages used in the current session? If TRUE, uses \code{\link[checkpoint]{scanForPackages}}, otherwise uses \code{\link[utils]{sessionInfo}}. | ||
#' @param include.rmd Logical. Include packages used in Rmarkdown documents? (default is TRUE, requires \code{knitr} package). | ||
#' @param style Optional. Citation style to format references. See \url{http://citationstyles.org/styles/}. | ||
#' @param out.format Output format, either "word", "pdf", "html", or "md" (markdown). | ||
#' @param ... Other parameters passed to \code{\link[checkpoint]{scanForPackages}}. | ||
#' | ||
#' @return A document with rendered citations in the desired format, plus a file ("pkg-refs.bib") containing references in BibTeX format. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' library(grateful) | ||
#' cite_packages() | ||
#' | ||
cite_packages <- function(all.pkg = TRUE, include.rmd = TRUE, style = NULL, | ||
out.format = "html", ...) { | ||
|
||
pkgs <- scan_packages(all.pkgs = all.pkg, include.Rmd = include.rmd, ...) | ||
cites <- get_citations(pkgs) # produces "pkg-refs.bib" file | ||
rmd <- create_rmd(cites, csl = style) # produces "refs.Rmd" | ||
render_citations(rmd, output = out.format) | ||
|
||
file.remove(rmd) | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.