Reproducible Research: Running odfWeave with 7-zip
[This article was first published on theBioBucket*, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
odfWeave is an R-package that is used for making dynamic reports by Sweave processing of Open Document Format (ODF) files. For anyone new to report generation and lacking knowledge of markup languages this might be a good starting point or even a true alternative to sweave / LATEX and others.Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Now, anyone who recently tried to install the required zipping program for odfWeave might have noticed that there are currently no info-zip executables available (zip and unzip by info-zip software are suggested in the odfWeave manual). There are several other free zipping programs – but if you use these the default syntax for odfWeave changes. Looking into the internals it is revealed that the OS command specified for running the zipping program has to be adapted. There are some postings on the R-help mailing list concerning these topic, but none of them worked for me. After some trial and error I managed to get around this problem by using 7-zip with an adapted syntax and will share this here:
# write an in-file and save it to a folder: dir() [1] "Example_1_in.odt" # testing the : system("\"C:\\Program Files\\7-Zip\\7z.exe\" t -tzip Example_1_in.odt") 7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 Processing archive: Example_1_in.odt Testing mimetype Testing Configurations2\statusbar Testing Configurations2\accelerator\current.xml Testing Configurations2\floater Testing Configurations2\popupmenu Testing Configurations2\progressbar Testing Configurations2\menubar Testing Configurations2\toolbar Testing Configurations2\images\Bitmaps Testing content.xml Testing manifest.rdf Testing styles.xml Testing meta.xml Testing Thumbnails\thumbnail.png Testing settings.xml Testing META-INF\manifest.xml Everything is Ok Folders: 7 Files: 9 Size: 30139 Compressed: 9572 # setting up cmd prompt: library(odfWeave) ctrl <- odfWeaveControl(zipCmd = c("\"C:\\Program Files\\7-Zip\\7z.exe\" a $$file$$", "\"C:\\Program Files\\7-Zip\\7z.exe\" x -tzip $$file$$")) # running: odfWeave("Example_1_in.odt", "Example_1_out.odt", control = ctrl) Copying Example_1_in.odt Setting wd to C:\Users\Kay\AppData\Local\Temp\RtmpghYef5/odfWeave2223195249 Unzipping ODF file using "C:\Program Files\7-Zip\7z.exe" x -tzip "Example_1_in.odt" 7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 Processing archive: Example_1_in.odt Extracting mimetype Extracting Configurations2\statusbar Extracting Configurations2\accelerator\current.xml Extracting Configurations2\floater Extracting Configurations2\popupmenu Extracting Configurations2\progressbar Extracting Configurations2\menubar Extracting Configurations2\toolbar Extracting Configurations2\images\Bitmaps Extracting content.xml Extracting manifest.rdf Extracting styles.xml Extracting meta.xml Extracting Thumbnails\thumbnail.png Extracting settings.xml Extracting META-INF\manifest.xml Everything is Ok Folders: 7 Files: 9 Size: 30139 Compressed: 9572 Removing Example_1_in.odt Creating a Pictures directory Pre-processing the contents Sweaving content.Rnw Writing to file content_1.xml Processing code chunks ... 'content_1.xml' has been Sweaved Removing content.xml Post-processing the contents Removing content.Rnw Removing styles.xml Renaming styles_2.xml to styles.xml Removing manifest.xml Renaming manifest_2.xml to manifest.xml Removing extra files Packaging file using "C:\Program Files\7-Zip\7z.exe" a "Example_1_in.odt" 7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 Scanning Creating archive Example_1_in.odt Compressing Configurations2\accelerator\current.xml Compressing content.xml Compressing manifest.rdf Compressing META-INF\manifest.xml Compressing meta.xml Compressing mimetype Compressing settings.xml Compressing styles.xml Compressing Thumbnails\thumbnail.png Everything is Ok Copying Example_1_in.odt Resetting wd Removing C:\Users\Kay\AppData\Local\Temp\RtmpghYef5/odfWeave2223195249 Done # see the result: dir() [1] "Example_1_in.odt" "Example_1_out.odt"
To leave a comment for the author, please follow the link and comment on their blog: theBioBucket*.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.