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

Duncan Murdoch murdoch.duncan at gmail.com
Thu Apr 12 14:21:48 CEST 2012

On 12-04-11 11:28 AM, Ken Williams wrote:
> I've made a small enhancement to R that would help developers better control what versions of code we're using where.  Basically, to load a package in R, one currently does:
>                  library(whateverPackage)
> and with the enhancement, you can ensure that you're getting at least version X of the package:
>                  library(whateverPackage, version=3.14)
> Reasons one might want this include:
>    * you know that in version X some bug was fixed
>    * you know that in version X some feature was added
>    * that's the first version you've actually tested it with&  you don't want to vouch for earlier versions without testing
>    * you develop on one machine&  deploy on another machine you don't control, and you want runtime checks that the sysadmin installed what they were supposed to install

I don't really see the need for this.  Packages already have a scheme 
for requiring a particular version of a package, so this would only be 
useful in scripts run outside of packages.  But what if your script 
requires a particular (perhaps obsolete) version of a package?  This 
change only puts a lower bound on the version number, and version 
requirements can be more elaborate than that.

I think my advice would be:

1.  Put your code in a package, and use the version specifications there.

2.  If you must write it in a script, then put a version test at the 
top, using packageVersion().

Duncan Murdoch

> In general, I have an interest in helping R get better at various things that would help it play in a "production environment", for various values of that term. =)
> The attached patch is made against revision 58980 of https://svn.r-project.org/R/trunk .  I think this is the first patch I've submitted to the R core, so please let me know if anything's amiss, or of course if there are reservations about the approach.
> Thanks.
> --
> Ken Williams, Senior Research Scientist
> WindLogics
> http://windlogics.com
> CONFIDENTIALITY NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution of any kind is strictly prohibited. If you are not the intended recipient, please contact the sender via reply e-mail and destroy all copies of the original message. Thank you.
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

More information about the R-devel mailing list