Well, I know this is true for the default Sweave(), and my problem actually comes from the pgfSweave package: I used some tricks to "cheat" R to parse and deparse the code chunks so that the output can be automatically formatted (and preserve the comments, [1]). The price to pay for not being "honest" is these line numbers since R 2.12.0 (even if there are no errors in my code). As I am unable to figure out the logic behind Sweave() to generate line numbers, I cannot modify my code either. So a temporary dirty solution is to turn off the reporting of line numbers.
I wish the keep.source=FALSE option can preserve comments so that we don't need to touch utils:::RweaveLatexRuncode ([2]). Formatting the code chunks is really a nice feature with keep.source=FALSE, but the price of discarding comments is too high... I think the evaluate package might be a good place to look at (or perhaps the highlight package), which performs just like the R terminal (keep the comments and report the errors without really stopping R, [3]). Thanks! [1] https://github.com/cameronbracken/pgfSweave/blob/master/R/pgfSweaveDriver.R#L297 [2] http://yihui.name/en/wp-content/uploads/2009/11/Sweave2.pdf [3] see the error in the last but one example: http://had.co.nz/ggplot2/stat_smooth.html Regards, Yihui -- Yihui Xie <xieyi...@gmail.com> Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Tue, Nov 2, 2010 at 5:09 PM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote: > On 02/11/2010 5:50 PM, Yihui Xie wrote: >> >> Hi, >> >> I thumbed through the source code Sweave.R but was unable to figure >> out when (under what conditions) R will insert the line numbers to the >> output. The R 2.12.0 news said: >> >> • Parsing errors detected during Sweave() processing will now be >> reported referencing their original location in the source file. >> >> Do we have any options to turn off this reporting? Thanks! > > Sure: just don't include any syntax errors. > > Duncan Murdoch > ______________________________________________ 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.