Why I Ditched Sweave for odfWeave

Well, I didn’t really – not completely. Sweave is an incredible tool for research. It facilitates replicable research to the benefit of researchers, too. Here is the main reason that cut it for me: getting back to a paper after a few weeks or months – think working on multiple papers, think hearing back from reviewers –, and not remembering all the details. For example, a figure or number looks odd, and by using Sweave I can immediately see where it comes from. Another reason is that I don’t want to avoid the following situation from the other end: I recently asked an author about a detail in a recently published paper. The response was “I can’t remember, I did the analysis some 2 year ago.” Using a single Sweave file, I also avoid confusion on the level of filenames (compare here or here).

So what is the problem with Sweave? There are two. First, on some papers I collaborate with others who don’t use R and Latex. Second, most journals in political sciences and sociology don’t accept Latex files. Enters odfWeave, doing almost everything Sweave does using LibreOffice rather than Latex. Creating Word documents for commenting and submission is easy. It also plays nicely with Zotero – which I find a bit easier to work in than Bibtex. (One annoyance: odfWeave hates relative paths.)

I said that I did not really ditch Sweave. For first drafts, I still like the accessibility, non-distraction, and compatibility of a plain text file. Usually I use heavily commented R-code, but Sweave is never far, especially as I can keep all analysis and plots in a single file.

12 Replies to “Why I Ditched Sweave for odfWeave”

  1. Just a small aside: on my underpowered netbook, odfWeave sometimes messes up (skips some of the code, a bit like when I throw too many lines of code at R using the clipboard), whereas Sweave never does. odfWeave can also be a bit fiddly with using different styles, namely if the style changes within a code block. Unfortunately, unlike Latex, it is more difficult to see this in LibreOffice, given that we’re not working with the source code of the document.

  2. Hi Didier,
    I can relate to what you’re saying. LaTeX/Sweave is excellent, until you try to interact with other authors or publishers who are unable to deal with anything other than Word. For much the same reasons, I’m trying out odfWeave and it looks promising. I’ve run into problems however, which has to do with paths (a source command embedded in the odf fails with ‘no such file’). I’m curious what you mean by “odfWeave hates relative paths”, how this has been a problem for you and how you have overcome it.

    1. I like to keep my data files in a separate folder. In Sweave a command like load(“../Data/File.RData”) causes no problem (or the source command you mention); in odfWeave I also get errors. The solution is relatively simple: use absolute paths, like load(“D:/Stuff/Data/File.RData”). (I’m not sure about the direction of the slashes under Windows, I’m making this up.). However, I find this unsatisfactory, since it breaks using the file on two locations (think Dropbox), unless the absolute paths are exactly the same on the two computers. The reason, by the way, why odfWeave has issues with relative paths, I think, has to due with the fact that the files are uncompressed into a temporary folder and then re-assembled; Sweave works in the folder itself.

  3. I’m not a windows user :-)
    I’ve learned the truth about relative and absolute pathways, the hard way too.
    Have you tried submitting a paper based on odfWeave yet?

  4. Well, it depends on what you mean, but yes. Some journals accept PDF for review, but require a Word document for the final submission. In this case using plain Sweave also works; requiring work once the paper is accepted. In many other cases, journals in my area ask for Word documents in a way that requires disassembling documents anyway (e.g. separate tables and figures). That said, I found the collaboration bit much more challenging than the submissions. Basically the solution depends on whom I work with. An alternative I used frequently recently is Sweave or heavily commented .R files and Word: do the analysis (and replication) in Sweave/.R files, write in Word. This gives me two documents rather than one, but is better than a collection of output and code scattered around files and folders.

  5. I’ve run into a spot of trouble, which just seems weird(!). I’m getting a lot of :
    Error in parse(text = cmd) : :1:1: unexpected ‘<'
    1: <

    Even with very simple stuff. Do you know if the typographic formatting makes a difference — I've changed a lot of text styles in my .odt document.
    Also – have you come across a good IRC channel or community forum ?

    1. I’m not sure I can help you directly. As for the community forum, have you tried Stack Overflow? As for the error, I regularly run into issues when I format the ODT files. I’m usually working around this by leaving the file quite plain in terms of formatting while running odfWeave, and finishing it at the end. If I changed only one part of the document, often I was able to use the format painter or equivalent steps to remove formatting in the ODT file (in the section affected) and the error goes away. With many changes, I commonly fail to spot what’s wrong, which is quite frustrating.

      My suspicion is that it’s got something to do with the beginning/end tags of the formatting, but I really don’t know enough about the ODT format. So changing styles in “Styles and Formatting” would be fine; but I’m guessing here.

  6. Just in case someone else comes looking here, I solved my problem: occasionally formatting has been added and removed, and formatting tags remain in the XML code (which is not displayed within Libreoffice). The simple solution was to highlight the area in the odf document, choose ‘clear foamtting’ from the typography style dropdown and .. wupti, it’s fine :-)

  7. I thought I’d mention it somewhere: Sweave is much faster than odfWeave. This isn’t surprising, since odfWeave does many things on top of Sweaving…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: