Hello All, Have recently started learning Sweave and Knitr. Am now trying to learn odfWeave as well. Things went pretty smoothly with Sweave and Knitr but I'm having some trouble with odfWeave. My understanding was that odfWeave should work in pretty much the same way as Sweave. With odfWeave, you set up an input .odt file in a folder, run that file through the odfWeave function, and then the function produces an output .odt file in the same folder. So I decided to try that using a file called simple.odt that comes with the odfWeave package. Unfortunately, things didn't work out quite as I had hoped. Below is the result of my attempt to odfWeave that file via Emacs. For some reason, odfWeave is setting the wd to a location on the C drive when my input file is on the N drive. I tried altering this by setting the location of workDir to my folder on the N drive. odfWeave through up an error saying that this folder already exists. So perhaps the files are supposed to be processed in a location other than the one where the input file resides. The other thing is that odfWeave is finding an unexpected "&". There is text in the "simple.odt" input file that looks like "paste(levels(iris$Species), collapse = " but it has no "&". So presumably something is wrong in the xml markup that is being produced. If anyone can help me understand what is going wrong here, that would be greatly appreciated. Thanks, Paul> library(odfWeave)Loading required package: lattice Loading required package: XML> inFile <- paste(fp, "simple.odt", sep="") > outFile <- paste(fp, "output.odt", sep="") > odfWeave(inFile, outFile)Copying N:/Studies/HCRPC1211/Documentation/R Documentation/odfWeave Documentation/Examples/Example 1/simple.odt Setting wd to C:\Users\pmiller\AppData\Local\Temp\3\RtmpMlDMHV/odfWeave18071055703 Unzipping ODF file using unzip -o "simple.odt" Archive: simple.odt extracting: mimetype inflating: meta.xml inflating: settings.xml inflating: content.xml extracting: Thumbnails/thumbnail.png inflating: layout-cache inflating: manifest.rdf creating: Configurations2/popupmenu/ creating: Configurations2/images/Bitmaps/ creating: Configurations2/toolpanel/ creating: Configurations2/statusbar/ creating: Configurations2/toolbar/ creating: Configurations2/progressbar/ creating: Configurations2/menubar/ creating: Configurations2/floater/ inflating: Configurations2/accelerator/current.xml inflating: styles.xml inflating: META-INF/manifest.xml Removing simple.odt Creating a Pictures directory Pre-processing the contents Sweaving content.Rnw Writing to file content_1.xml Processing code chunks ... Error in parse(text = cmd) : <text>:1:40: unexpected '&' 1: paste(levels(iris$Species), collapse = & ^>[[alternative HTML version deleted]]
That's not a reproducible example. There is no sessionInfo() and you omitted code (where did 'fp' come from?). It works fine for me (see sessionInfo below) using the code in ?odfWeave. As for the file paths: you can point to different paths for the files (although don't change the working directory in the odt file). If you read the documentation for workDir: "a path to a directory where the source file will be unpacked and processed. If it does not exist, it will be created. If it exists, it should be empty, since all its contents will be included in the generated file". The default value should be sufficient. Max> sessionInfo()R version 2.15.2 (2012-10-26) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] MASS_7.3-22 odfWeave_0.8.2 XML_3.95-0.1 lattice_0.20-10 loaded via a namespace (and not attached): [1] tools_2.15.2 On Mon, Feb 18, 2013 at 8:52 AM, Paul Miller <pjmiller_57@yahoo.com> wrote:> Hello All, > > Have recently started learning Sweave and Knitr. Am now trying to learn > odfWeave as well. Things went pretty smoothly with Sweave and Knitr but I'm > having some trouble with odfWeave. > > My understanding was that odfWeave should work in pretty much the same way > as Sweave. With odfWeave, you set up an input .odt file in a folder, run > that file through the odfWeave function, and then the function produces an > output .odt file in the same folder. > > So I decided to try that using a file called simple.odt that comes with > the odfWeave package. Unfortunately, things didn't work out quite as I had > hoped. Below is the result of my attempt to odfWeave that file via Emacs. > > For some reason, odfWeave is setting the wd to a location on the C drive > when my input file is on the N drive. I tried altering this by setting the > location of workDir to my folder on the N drive. odfWeave through up an > error saying that this folder already exists. So perhaps the files are > supposed to be processed in a location other than the one where the input > file resides. > > The other thing is that odfWeave is finding an unexpected "&". There is > text in the "simple.odt" input file that looks like > "paste(levels(iris$Species), collapse = " but it has no "&". So presumably > something is wrong in the xml markup that is being produced. > > If anyone can help me understand what is going wrong here, that would be > greatly appreciated. > > Thanks, > > Paul > > > library(odfWeave) > Loading required package: lattice > Loading required package: XML > > inFile <- paste(fp, "simple.odt", sep="") > > outFile <- paste(fp, "output.odt", sep="") > > odfWeave(inFile, outFile) > Copying N:/Studies/HCRPC1211/Documentation/R Documentation/odfWeave > Documentation/Examples/Example 1/simple.odt > Setting wd to > C:\Users\pmiller\AppData\Local\Temp\3\RtmpMlDMHV/odfWeave18071055703 > Unzipping ODF file using unzip -o "simple.odt" > Archive: simple.odt > extracting: mimetype > inflating: meta.xml > inflating: settings.xml > inflating: content.xml > extracting: Thumbnails/thumbnail.png > inflating: layout-cache > inflating: manifest.rdf > creating: Configurations2/popupmenu/ > creating: Configurations2/images/Bitmaps/ > creating: Configurations2/toolpanel/ > creating: Configurations2/statusbar/ > creating: Configurations2/toolbar/ > creating: Configurations2/progressbar/ > creating: Configurations2/menubar/ > creating: Configurations2/floater/ > inflating: Configurations2/accelerator/current.xml > inflating: styles.xml > inflating: META-INF/manifest.xml > Removing simple.odt > Creating a Pictures directory > Pre-processing the contents > Sweaving content.Rnw > Writing to file content_1.xml > Processing code chunks ... > Error in parse(text = cmd) : <text>:1:40: unexpected '&' > 1: paste(levels(iris$Species), collapse = & > ^ > > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@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. > >-- Max [[alternative HTML version deleted]]
Hi Max, ? Sorry I didn't provide sufficient information. Below is my sessionInfo with all code included. ? Thanks, ? Paul ? sessionInfo() R version 2.13.1 (2011-07-08) Platform: x86_64-pc-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252?? [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C????????????????????????? [5] LC_TIME=English_United States.1252??? attached base packages: [1] stats???? graphics? grDevices utils???? datasets? methods?? base????> > ################## > #### odfWeave #### > ################## > > .libPaths("C:/Users/pmiller/Documents/R/win-library/2.13") > > #### Set path to odt files #### > > fp <- "N:/Studies/HCRPC1211/Documentation/R Documentation/odfWeave Documentation/Examples/Example 1/" > > #### Weave odt source file #### > > library(odfWeave)Loading required package: lattice Loading required package: XML> inFile? <- paste(fp, "simple.odt", sep="") > outFile <- paste(fp, "output.odt", sep="") > odfWeave(inFile, outFile)? Copying? N:/Studies/HCRPC1211/Documentation/R Documentation/odfWeave Documentation/Examples/Example 1/simple.odt ? Setting wd to? C:\Users\pmiller\AppData\Local\Temp\3\Rtmp2lSWXe/odfWeave18104355174 ? Unzipping ODF file using unzip -o "simple.odt" Archive:? simple.odt ?extracting: mimetype??????????????? ? inflating: meta.xml??????????????? ? inflating: settings.xml??????????? ? inflating: content.xml???????????? ?extracting: Thumbnails/thumbnail.png? ? inflating: layout-cache??????????? ? inflating: manifest.rdf??????????? ?? creating: Configurations2/popupmenu/ ?? creating: Configurations2/images/Bitmaps/ ?? creating: Configurations2/toolpanel/ ?? creating: Configurations2/statusbar/ ?? creating: Configurations2/toolbar/ ?? creating: Configurations2/progressbar/ ?? creating: Configurations2/menubar/ ?? creating: Configurations2/floater/ ? inflating: Configurations2/accelerator/current.xml? ? inflating: styles.xml????????????? ? inflating: META-INF/manifest.xml?? ? Removing? simple.odt ? Creating a Pictures directory ? Pre-processing the contents ? Sweaving? content.Rnw ? Writing to file content_1.xml ? Processing code chunks ... Error in parse(text = cmd) : <text>:1:40: unexpected '&' 1: paste(levels(iris$Species), collapse = & ????????????????????????????????????????? ^> >--- On Mon, 2/18/13, Max Kuhn <mxkuhn at gmail.com> wrote: From: Max Kuhn <mxkuhn at gmail.com> Subject: Re: [R] odfWeave: Trouble Getting the Package to Work To: "Paul Miller" <pjmiller_57 at yahoo.com> Cc: "r-help at r-project.org" <r-help at r-project.org> Received: Monday, February 18, 2013, 8:47 AM That's not a reproducible example. There is no sessionInfo() and you omitted code (where did 'fp' come from?). It works fine for me (see sessionInfo below) using the code in ?odfWeave. As for?the?file paths: you can point to different paths for the files (although don't change?the?working directory in the odt file). If you read the documentation for workDir: "a path to a directory where the source file will be unpacked and processed. If it does not exist, it will be created. If it exists, it should be empty, since all its contents will be included in the generated file". The default value should be sufficient.? Max> sessionInfo()R version 2.15.2 (2012-10-26) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid ? ? ?stats ? ? graphics ?grDevices utils ? ? datasets ?methods ? base ? ?? other attached packages: [1] MASS_7.3-22 ? ? odfWeave_0.8.2 ?XML_3.95-0.1 ? ?lattice_0.20-10 loaded via a namespace (and not attached): [1] tools_2.15.2 On Mon, Feb 18, 2013 at 8:52 AM, Paul Miller <pjmiller_57 at yahoo.com> wrote: Hello All, Have recently started learning Sweave and Knitr. Am now trying to learn odfWeave as well. Things went pretty smoothly with Sweave and Knitr but I'm having some trouble with odfWeave. My understanding was that odfWeave should work in pretty much the same way as Sweave. With odfWeave, you set up an input .odt file in a folder, run that file through the odfWeave function, and then the function produces an output .odt file in the same folder. So I decided to try that using a file called simple.odt that comes with the odfWeave package. Unfortunately, things didn't work out quite as I had hoped. Below is the result of my attempt to odfWeave that file via Emacs. For some reason, odfWeave is setting the wd to a location on the C drive when my input file is on the N drive. I tried altering this by setting the location of workDir to my folder on the N drive. odfWeave through up an error saying that this folder already exists. So perhaps the files are supposed to be processed in a location other than the one where the input file resides. The other thing is that odfWeave is finding an unexpected "&". There is text in the "simple.odt" input file that looks like "paste(levels(iris$Species), collapse = " but it has no "&". So presumably something is wrong in the xml markup that is being produced. If anyone can help me understand what is going wrong here, that would be greatly appreciated. Thanks, Paul> library(odfWeave)Loading required package: lattice Loading required package: XML> inFile? <- paste(fp, "simple.odt", sep="") > outFile <- paste(fp, "output.odt", sep="") > odfWeave(inFile, outFile)? Copying? N:/Studies/HCRPC1211/Documentation/R Documentation/odfWeave Documentation/Examples/Example 1/simple.odt ? Setting wd to? C:\Users\pmiller\AppData\Local\Temp\3\RtmpMlDMHV/odfWeave18071055703 ? Unzipping ODF file using unzip -o "simple.odt" Archive:? simple.odt ?extracting: mimetype??????????????? ? inflating: meta.xml??????????????? ? inflating: settings.xml??????????? ? inflating: content.xml???????????? ?extracting: Thumbnails/thumbnail.png? ? inflating: layout-cache??????????? ? inflating: manifest.rdf??????????? ?? creating: Configurations2/popupmenu/ ?? creating: Configurations2/images/Bitmaps/ ?? creating: Configurations2/toolpanel/ ?? creating: Configurations2/statusbar/ ?? creating: Configurations2/toolbar/ ?? creating: Configurations2/progressbar/ ?? creating: Configurations2/menubar/ ?? creating: Configurations2/floater/ ? inflating: Configurations2/accelerator/current.xml? ? inflating: styles.xml????????????? ? inflating: META-INF/manifest.xml?? ? Removing? simple.odt ? Creating a Pictures directory ? Pre-processing the contents ? Sweaving? content.Rnw ? Writing to file content_1.xml ? Processing code chunks ... Error in parse(text = cmd) : <text>:1:40: unexpected '&' 1: paste(levels(iris$Species), collapse = & ????????????????????????????????????????? ^>? ? ? ? [[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. -- Max