[R] Project local libraries (reproducible research)

Jim Lemon jim at bitwrit.com.au
Sat Dec 3 12:16:32 CET 2011

On 12/03/2011 06:04 AM, Hadley Wickham wrote:
> Hi all,
> I was wondering if any one had scripts that they could share for
> capturing the current version of R packages used for a project. I'm
> interested in creating a project local library so that you're safe if
> someone (e.g. the ggplot2 author) updates a package you're relying on
> and breaks your code.   I could fairly easily hack together, but I was
> wondering if any one had any neat scripts they'd care to share.
Hi Hadley,
This makes quite a few assumptions, but I would build a list of packages 
called in R scripts:

# get all calls to library or require in a subdirectory of scripts
packagestrings<-c(system("grep library *.R",intern=TRUE),
  system("grep require *.R",intern=TRUE))
# get the unique package names
# get the information on all installed packages in the system
# get the indices of the packages used in the subdirectory
# get the version information for each used package


More information about the R-help mailing list