cboettig / knitcitations

:package: Generate citations for knitr markdown and html files
http://carlboettiger.info
Other
220 stars 28 forks source link

WISH: Memoize citet() etc. #71

Closed HenrikBengtsson closed 9 years ago

HenrikBengtsson commented 9 years ago

It would be great if citation look ups would be memoized. For instance, if I call citet("10.1098/rspb.2013.1372") multiple times, it's only the first one that query online resources, whereas all the following would be pull from the local cache/database.

cboettig commented 9 years ago

@HenrikBengtsson Good idea. You can manage this with something like:

Hastings <- bib_metadata("10.1098/rspb.2013.1372") and then do citet(Hastings) afterwards.

Originally I had a mechanism to assign the bibtex key during the call to citet, but this seemed a bit cumbersome. Lemme know if this work-around will do it for you. If you literally want to use the DOI each time I guess we could look into caching after the first call; might be a good thing to do but caching can always get tricky pretty quickly (e.g. during interactive use).

HenrikBengtsson commented 9 years ago

I like this "pre-fetch" solution where the reference becomes first-class objects in R. It's not hard to imagine using code inspection to validate that all reference variables exists basically directly parsing. This should be less error prone that referring to references by strings, which can only be caught as an error at run time.

EDIT: Forgot to say, yes, this works for me.

cboettig commented 9 years ago

(looks like we have a working solution so closing this)