[I originally emailed this to Friedrich Leisch but got no response and I just wanted to make sure it made it in before release.]

While working with Stangle(), I noticed a problem when using 'split = TRUE'. Particularly, when there are two chunks where one chunk's name is a prefix of another chunk's name, then the two chunks will be written to a single file rather than two separate files (if the chunk who's name is a prefix comes after the other chunk). Running 'Stangle(split=TRUE)' with the attached 'test1.Rnw' file should reproduce the problem.

I think it boils down to a partial matching problem in 'RtangleRuncode'. I've attached a patch against R-alpha (r41020) which I think fixes this problem but I'm not sure it's necessarily the best approach (there are other instances of this construction in the code).

-roger
--
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/
Index: src/library/utils/R/Sweave.R
===================================================================
--- src/library/utils/R/Sweave.R        (revision 41020)
+++ src/library/utils/R/Sweave.R        (working copy)
@@ -854,7 +854,7 @@
         outfile <- paste(chunkprefix, options$engine, sep=".")
         if(!object$quiet)
             cat(options$chunknr, ":", outfile,"\n")
-        chunkout <- object$chunkout[[chunkprefix]]
+        chunkout <- object$chunkout[chunkprefix][[1]]
         if(is.null(chunkout)){
             chunkout <- file(outfile, "w")
             if(!is.null(options$label))
<<abcde,echo=true>>=
y <- 2
@

<<abcd,echo=true>>=
x <- 1
@

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to