[R] Creating bibtex file of all installed packages?

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Fri Dec 11 08:41:28 CET 2009


On Fri, 11 Dec 2009, Rainer M Krug wrote:

> Hi
>
> is there an easy and fast way, to generate a BibTeX file of all installed /
> loaded packages and R?
>
> I know about toBibtex(citation()) to extract the BibTeX for a single
> package, but how can I generate a file containg citations for all installed
> / loaded packages?

I don't think that there is a way other than calling citation() for each 
of the installed.packages(). You could do something like this:

## try to get BibTeX for each of the installed packages
b <- lapply(installed.packages()[,1], function(x)
   try(toBibtex(citation(x))))
## omit failed citation calls
b <- b[-which(sapply(b, class) == "try-error")]
## unify to list of Bibtex
b <- lapply(b, function(x) if(inherits(x, "Bibtex")) list(x) else x)
## list of unique entries
b <- unique(do.call("c", b))
## write everything to a single .bib file
writeLines(do.call("c", lapply(b, as.character)), "Rpackages.bib")

hth,
Z

> Cheers,
>
> Rainer
>
> -- 
> NEW GERMAN FAX NUMBER!!!
>
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
> UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Natural Sciences Building
> Office Suite 2039
> Stellenbosch University
> Main Campus, Merriman Avenue
> Stellenbosch
> South Africa
>
> Cell:           +27 - (0)83 9479 042
> Fax:            +27 - (0)86 516 2782
> Fax:            +49 - (0)321 2125 2244
> email:          Rainer at krugs.de
>
> Skype:          RMkrug
> Google:         R.M.Krug at gmail.com
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
>




More information about the R-help mailing list