As hrbrmstr pointed out, a function to create a list of references of only loaded packages would come in handy. As he only showed us an example and not the function, I wrote one myself which I use very often in scientific analyses and papers (sometimes combined with R Markdown).
citations <- function(includeURL = TRUE, includeRStudio = TRUE) {
if(includeRStudio == TRUE) {
ref.rstudio <- RStudio.Version()$citation
if(includeURL == FALSE) {
ref.rstudio$url <- NULL;
}
print(ref.rstudio, style = 'text')
cat('\n')
}
cit.list <- c('base', names(sessionInfo()$otherPkgs))
for(i in 1:length(cit.list)) {
ref <- citation(cit.list[i])
if(includeURL == FALSE) {
ref$url <- NULL;
}
print(ref, style = 'text')
cat('\n')
}
}
So, for example, after running
library(readr)
library(dplyr)
library(ggplot2)
library(knitr)
the function citations()
will print:
RStudio Team (2016). RStudio: Integrated Development Environment for R. RStudio, Inc., Boston, MA.
http://www.rstudio.com.
R Core Team (2017). R: A Language and Environment for Statistical Computing. R Foundation for Statistical
Computing, Vienna, Austria. https://www.R-project.org.
Xie Y (2016). knitr: A General-Purpose Package for Dynamic Report Generation in R. R package version 1.15.1, http://yihui.name/knitr.
Xie Y (2015). Dynamic Documents with R and knitr, 2nd edition. Chapman and Hall/CRC, Boca Raton, Florida.
ISBN 978-1498716963, http://yihui.name/knitr.
Xie Y (2014). “knitr: A Comprehensive Tool for Reproducible Research in R.” In Stodden V, Leisch F and Peng RD
(eds.), Implementing Reproducible Computational Research. Chapman and Hall/CRC. ISBN 978-1466561595,
http://www.crcpress.com/product/isbn/9781466561595.
Wickham H (2009). ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. ISBN
978-0-387-98140-6, http://ggplot2.org.
Wickham H and Francois R (2016). dplyr: A Grammar of Data Manipulation. R package version 0.5.0, https://CRAN.R-project.org/package=dplyr.
Wickham H, Hester J and Francois R (2016). readr: Read Tabular Data. R package version 1.0.0, https://CRAN.R-project.org/package=readr.