On 12/16/2009 10:12 AM, Achim Zeileis wrote: > On Wed, 16 Dec 2009, S Devriese wrote: > >> On 12/16/2009 08:32 AM, Achim Zeileis wrote: >>> On Tue, 15 Dec 2009, Michael Friendly wrote: >>> >>>> Achim and others: >>>> >>>> Achim's solution could be directly usable if it also added a BibTeX >>>> key, >>>> perhaps just the name of the package to the '@Manual{,' initial line >>>> of each. I wrapped the previous suggestions in a function, and played >>>> around with the components, but can't quite see how to account for the >>>> failed citation calls. Can anyone take the next step? >>> >>> I had also thought about this after sending my previous solution, so >>> here is an update Michael's version of the function (renamed to the >>> name of the default file). Apart from some smaller touch-ups this has >>> the following changes: >>> >>> - Instead of taking the unique() bibs, I now use the unique() pkgs. >>> >>> (In principle, packages with the same name could be installed in >>> different libraries, potentially containing different citations. >>> But I thought it would be overkill to check for that.) >>> >>> - Citation keys are simply "pkgname" if there is only a single >>> BibTeX item, and "pkgname1" to "pkgnameN" if there are N BibTeX >>> items. >>> >>> (This does not assure that citation keys are unique, though. If >>> there is a package "foo" with 2 citation entries and another >>> package >>> "foo2" with only a single entry, these could be confused. A >>> workaround >>> would be to use "pkgname1" instead of "pkgname" as the citation key >>> even if there is a single citation only. But I thought that would >>> be less intuitive.) >> Another possibility would be to use pkgname_versionnumber (e.g. >> lattice1226). This would probably provide uniqueness and if used on >> subsequent updates of packages does not break older (latex) documents >> where previous versions of packages were used. >> Just a thought. > > No, it doesn't. As pointed out above, the function currently only > calls citation() once for each package name (i.e., ignores multiple > versions if any). The multiple entries do not stem from multiple > versions of the package, but from multiple citations within a single > package. See > > citation("sandwich") > > for an example. > Z > I'm sorry my thoughts were somewhat confusing in the mail. I did catch that the current mechanism to avoid multiple entries solves the one package-multiple citations problem and not a multiple package-one citiation problem. I was just thinking of a way to alter the function when used sequentially in time. I know that was not the original poster's problem, but it's one I and several of my colleagues have encountered often (and until the function posted here, we used a more manual way of solving the problem of getting the citations of all installed (or loaded) packages :-). I know that simply using seperate .bib files for each latex document partially solves the sequential-in-time problem, but this is actually a different topic, so I probably should start a different thread.
Stephan ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.