How do I tell which R packages to cite in my paper?

719 Views Asked by At

The question of R "stats" citation for a scientific paper makes me wonder how I would enumerate all the R packages that I ought to cite when using R in an academic paper. How would I get a list of packages that I loaded and need citation?

1

There are 1 best solutions below

1
On

Using the answer to How to find out which package version is loaded in R? , I see that we can use the sessionInfo() function to see what packages have been loaded (though not necessarily used).

The following gets the base packages as a vector and concatenates it with the names of the loaded packages. Then we apply the citation function to each.

packages_in_use <- c( sessionInfo()$basePkgs, names( sessionInfo()$loadedOnly ) )
the_citations_list <- lapply( X=packages_in_use, FUN=citation)
the_citations_list