How to export an R citation output into endnote?

8.9k Views Asked by At

How can I easily import citations from R into endnote obtained by for instance

citation("ggplot2")

Is there a good workflow for this or do I manually have to do it?

1

There are 1 best solutions below

1
On BEST ANSWER

How automated this can be will depend on what Endnote can import. It seems BibTeX import is not currently possible out of the box, and requires some extra software. See for example: http://www.lib.uts.edu.au/content/faq/how-can-i-import-bibliography-endnote-bibtex-latex-what-about-converting-other-way-endno

Read ?bibentry and in particular the argument style and the Details section. See if Endnote can import data in any of those formats? I doubt it, but I have never used Endnote.

If not, we can go the BibTeX route if you install something that allows you to import BibTeX into Endnote.

> utils:::print.bibentry(citation("ggplot2"), style = "Bibtex")
@Book{,
  author = {Hadley Wickham},
  title = {ggplot2: elegant graphics for data analysis},
  publisher = {Springer New York},
  year = {2009},
  isbn = {978-0-387-98140-6},
  url = {http://had.co.nz/ggplot2/book},
}

To get this out into a file for passing to an import utility, you can use capture.output()

capture.output(utils:::print.bibentry(citation("ggplot2"), style = "Bibtex"),
               file = "endnote_import.bib")

Which gives a file with the following content:

$ cat endnote_import.bib 
@Book{,
  author = {Hadley Wickham},
  title = {ggplot2: elegant graphics for data analysis},
  publisher = {Springer New York},
  year = {2009},
  isbn = {978-0-387-98140-6},
  url = {http://had.co.nz/ggplot2/book},
}

which you should be able to import with third party tools.