A workflow for LibreOffice/Zotero/Rstudio and knitr

I am probably not alone in using LO and Zotero for writing and R/Rstudio for data analysis. I am interested to see if anyone else is interested in imagining an improved workflow for these tools.

Ok the R/Rstudio side of things, up until recently, the odfWeave package allows one to tear apart an odf XML file, add R-generated content, and then tidy it all back up into a new odf/XML file. But there are several problems:

- it was a very "batch" approach to things.
- I found it bulky and unwieldy at times
- it lacked the elegancy of knitr/latex, etc.

I am trying to imagine how one might get the same value out of LO/Zotero as one can get now from Zotero. I suppose in my dreams, Zotero and LibreOffice play together sufficiently nicely that you could escape from LO to Rstudio without great clutter or costs.

I'd welcome thoughts on how this might all come together.

Rob
  • I should have added that I am trying to imagine how to achieve some of the elegance that has gone into Rstudio/knitr's current integration to generate HTLM5 outputs, compile PDFs, etc.
  • I feel I'm completely missing what Zotero has to do with this. I understand R/R-studio to LO transfer issues, but I have no idea how/why Zotero should figure in there?
  • Ahh, ...clearly one wants to retain the Zotero functionality as well as have all the lovely Rstudio/knitr/sweave integration, but the current model in R/Rstudio is that one generates simple ASCII text - both for code and for commentary - so there's no place in that model for all the codes, etc. that make Zotero run with Libreoffice.

    I suspect that the strategy would have to be to grab the Latex or HTML5 generated out of R/Rstudio and bring that smoothly into LO.

    So, there are elements here of LO, Rstudio, and Zotero and the trick is asking if anyone else is trying to square this circle. I think it is worth doing, but many minds...

    Thanks,

    R
  • But once you have R output imported into Libre Office you can use Zotero.
    So the question really does seem to be how to get this into LO - you can certainly ask this here, but it does not seem to me to be the best place for it, because Zotero is only of accidental relevance and will not be part of any workflow.

    And far as Zotero goes, it also work in several other formats supported by R/knitr, including LaTeX/LyX via the Lyz plugin and reStructured Text via zotero-plain.
  • SalishSea, interesting idea. I would suggest creating an R-package that works as an intermediate in R-studio. I'm not that familiar with LyX but in my case I like to do everything in R-studio and LaTeX causes issues when converting to Word (which many orthopaedic-journals require).

    Here is how you would plug into the markdown process:

    # Note you have to run this before you run the knit HTML
    # as this is set prior to the knit session.
    options(rstudio.markdownToHTML =
    function(inputFile, outputFile) {
    require(markdown)
    require(zotero)
    z_processed <- zotero_translate(inputFile, outputFile)
    markdownToHTML(z_processed$inputFile, z_processed$outputFile)
    }
    )</pre>

    In the document I would either provide [zot:2344124] if I have the id (I actually don't know how to find the id's) or preferably just go with [zot:Miller et al. 2012] where I get a select box of the Miller et al on that year in case of conflicts. This shouldn't be that difficult to implement. The R-code should be rather straight forward but I'm not sure how to query Zotero from R. In addition it would be great if the references would be updated to unambiguous after the select box.
  • edited January 26, 2017
    This thread is several years old, and back then Adam Smith's comments were very apropos. But now Rstudio has added R Notebooks written in R Markdown to implement "literate programming." While I'm not yet ready to give up on tools designed primarily for preparing written documents, such as LO and LyX, I can certainly see the value of Zotero interfacing directly with documents (R Notebooks) prepared with R Markdown in Rstudio.

    For example, I'm currently working in LyX on a paper about the Great Recession. One figure is a graph of land prices over time and overlaid with a graph of the CPI and recession shading. I'm preparing this with Rstudio, and it would be great to have it in a notebook that contains information about how to construct and update the graph, notes about the underlying data, and observations about the patterns revealed. Each of the three data sources has its own citation requirements, and logically this should be included in the notebook. So this most definitely is a job for Zotero.

    Ideally, the stuff in the notebook would easily and selectively integrated into the LyX document, so there's no duplication of effort and appropriate changes automatically propagate to all documents that rely on the graph. While this is not primarily a Zotero issue, the relations between Zotero, the .bib file containing the references used in the paper, and the references used in the R Notebook (presumably stored in the same .bib file) may require some thought on the Zotero side. (LyZ comes to mind as a tool that might serve as a model.)
  • Have a look at Citr, which basically gives you Zotero integration with Rstudio: https://cran.rstudio.com/web/packages/citr/README.html
  • Thanks! I came across this thread because I had searched for "Zotero Rstudio." Shortly after leaving my comment, I came across a plugin for Rstudio that, if I read its description correctly, only works directly with the Juris-M version of Zotero. But Citr says either/or. This will make my life a bit easier.
  • The citr package is really fantastic. If you combine it with better bibtex, you can have an up-to-date library of all references, with insertion that's just as easy as the Zotero plugin for Word!
  • edited 8 days ago
    An example of using Zotero/BetterBibtex/rmarkdown/RStudio/citr/knitr to easily cite during writing and generate the references, including the R packages used.
    http://r.iresmi.net/2019/02/02/bibliography-with-knitr-cite-your-references-and-packages/
  • If anyone has a very very large Zotero database and runs into issues getting citr to work, also check out the rbbt package: https://github.com/paleolimbot/rbbt
Sign In or Register to comment.