[R-pkg-devel] referring to a package data object by two names

Gregory Jefferis jefferis at gmail.com
Sun Oct 8 09:40:28 CEST 2017


Dear R colleagues,

I have a set of versioned data objects in a package. Let's call them 

landmarks.2016
landmarks.2017

I need to have access to both of these objects for different calculations both internal to the package and for end users. The objects are saved as rda files in the package's data folder.

I would also like to define an object – an alias if you will – that contains the *current* landmarks. This is useful so that some package functions and external scripts do not require editing when the default object changes. 

For this, somewhere in the package, I would like to do something like:

# set the current default landmarks
landmarks <- landmarks.2017

I cannot figure out a place to do this in my package because check always complaints that landmarks.2017 does not exist – I guess lazy loading can only happen after all the R code is evaluated.

* Can anyone suggest a workaround that does not involve saving a third redundant rda object into the package's data folder?

I have placed a toy example package on GitHub:

  https://github.com/jefferis/testdataalias

With many thanks,

Greg Jefferis.

--
Gregory Jefferis, PhD
Division of Neurobiology
MRC Laboratory of Molecular Biology
Francis Crick Avenue
Cambridge Biomedical Campus
Cambridge, CB2 OQH, UK

http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://jefferislab.org
http://www.zoo.cam.ac.uk/departments/connectomics



More information about the R-package-devel mailing list