Duncan Murdoch
2010-Aug-19 19:07 UTC
[Rd] Does anyone use Sweave (RweaveLatex) option "expand=FALSE"?
I am trying to improve the error reporting in Sweave documents, so that if you have a syntax error in a code chunk, it will tell you which line of your input file contained the error. For example, currently you get this: Error: chunk 1 (label=named) Error in parse(text = chunk) : unexpected symbol in "x <- foo bar" Execution halted and I'd like errors to be more like this: Error: chunk 1 (label=named) Error in parse(text = chunk, srcfile = srcfile) : test.Rnw:9:10: unexpected symbol 9: x <- foo bar ^ Execution halted It turns out that this requires changes that make the "expand=FALSE" option quite hard to implement. Is anyone using it? For those who don't know it, "expand=FALSE" means that a code chunk like <<echo=TRUE, keep.source=TRUE,expand=FALSE>>z <- 3 <<named>> @ will be displayed as > z <- 3 > <<named>> rather than expanding the named chunk. I'd like to drop the option, so that the default behaviour (which has always been equivalent to "expand = TRUE") would be the only behaviour. Duncan Murdoch
Marc Schwartz
2010-Aug-19 19:17 UTC
[Rd] Does anyone use Sweave (RweaveLatex) option "expand=FALSE"?
On Aug 19, 2010, at 2:07 PM, Duncan Murdoch wrote:> I am trying to improve the error reporting in Sweave documents, so that if you have a syntax error in a code chunk, it will tell you which line of your input file contained the error. > > For example, currently you get this: > > Error: chunk 1 (label=named) > Error in parse(text = chunk) : unexpected symbol in "x <- foo bar" > Execution halted > > and I'd like errors to be more like this: > > Error: chunk 1 (label=named) > Error in parse(text = chunk, srcfile = srcfile) : > test.Rnw:9:10: unexpected symbol > 9: x <- foo bar > ^ > Execution halted > > It turns out that this requires changes that make the "expand=FALSE" option quite hard to implement. Is anyone using it? For those who don't know it, "expand=FALSE" means that a code chunk like > > <<echo=TRUE, keep.source=TRUE,expand=FALSE>>> z <- 3 > <<named>> > @ > > will be displayed as > > > z <- 3 > > <<named>> > > rather than expanding the named chunk. I'd like to drop the option, so that the default behaviour (which has always been equivalent to "expand = TRUE") would be the only behaviour. > > Duncan MurdochI don't. So 1 "go ahead and drop it" vote... You may want to post this to R-Help though Duncan, as I suspect there may be more Sweave users there than here... Thanks and regards, Marc Schwartz
Claudia Beleites
2010-Aug-19 20:29 UTC
[Rd] Does anyone use Sweave (RweaveLatex) option "expand=FALSE"?
I never used it. I got curious, though. What would be a situation that benefits of this option? Maybe a use case could be found by "brute force" (grep all .Rnw files on CRAN for the option? Claudia -- Claudia Beleites Dipartimento dei Materiali e delle Risorse Naturali Universit? degli Studi di Trieste Via Alfonso Valerio 6/a I-34127 Trieste phone: +39 0 40 5 58-37 68 email: cbeleites at units.it
Duncan Murdoch
2010-Aug-19 20:38 UTC
[Rd] Does anyone use Sweave (RweaveLatex) option "expand=FALSE"?
On 19/08/2010 4:29 PM, Claudia Beleites wrote:> I never used it. > > I got curious, though. What would be a situation that benefits of this option? >When I put it in, I thought it would be for people who were writing about Sweave. Duncan Murdoch> Maybe a use case could be found by "brute force" (grep all .Rnw files on CRAN > for the option? > > Claudia > >
Thank you Duncan, for expanding Sweave functionality, notably considering error handling. Related to that is the topic of handling warning messages. In a course on "using R" (for beginners), I would really like to show warnings that code chunks produce. Currently, the warnings are printed to the console when I run 'R CMD Sweave ..' and do not appear in the resulting *.tex file. Of course --- fortune("Yoda") --- I can always fudge what I want, but it would be quite desirable to have simple Sweave option which would deal with warnings() { and maybe message(), stop(), and general exception handling; but for all practical purposes, it's the warnings that I'd like to be handled automatically.} Martin Maechler, ETH Zurich
Terry Therneau
2010-Aug-20 16:14 UTC
[Rd] Does anyone use Sweave (RweaveLatex) option "expand=FALSE"?
Duncan, I use noweb for my R source code on the more complex projects (see the coxme package). I currently have my own "noweb.R" functions to do the work, but the overlap is so great with Sweave that I have hopes that they will one day merge. A note on <<abc>> recursion: for documentation this is very well designed; it's better than a macro or a function would be. And of course, documentation of code is what the system was designed for. And a general query: I currently have the .Rnw source files in the inst/noweb directory. Do people have a better suggestion? Remember these .Rnw files are the source of my .R files and of document explaining the code, not the source of vignettes or manual pages. Terry Therneau