Skip to content
Prev 43074 / 63424 Next

[patch] giving library() a 'version' argument

On 12/04/2012 11:11 AM, Ken Williams wrote:
I haven't tested it, but according to the documentation in Writing R 
Extensions, the dependencies are enforced at the time library() is called.
If the docs are wrong (or I misread them), you could equally put a 
run-time version test into the .onLoad function in a package.
But a single line at the top of the script would fix this:

stopifnot(packageVersion("foo") == "3.14")

Making the library() function more elaborate doesn't seem to add anything.
Another problem with putting this into library() is that packages aren't 
always loaded by library():  there is require(), and there are implicit 
loads triggered by dependencies of other packages.

Duncan Murdoch