Bug 14459 - Sweave() ignores 'keep.source=TRUE' (except for adding stray NAs)
Summary: Sweave() ignores 'keep.source=TRUE' (except for adding stray NAs)
Alias: None
Product: R
Classification: Unclassified
Component: Misc (show other bugs)
Version: R 2.12.0 patched
Hardware: x86_64/x64/amd64 (64-bit) All
: P5 normal
Assignee: R-core
Depends on:
Reported: 2010-12-15 21:23 UTC by John H Maindonald
Modified: 2015-12-14 13:46 UTC (History)
3 users (show)

See Also:

Process with Sweave("test01", keep.source=TRUE) (251 bytes, application/octet-stream)
2010-12-15 21:23 UTC, John H Maindonald
Process with Sweave("test00") (221 bytes, application/octet-stream)
2010-12-15 21:27 UTC, John H Maindonald

Note You need to log in before you can comment on or make changes to this bug.
Description John H Maindonald 2010-12-15 21:23:16 UTC
Created attachment 1158 [details]
Process with Sweave("test01", keep.source=TRUE)

The only effect of 'keep.source=TRUE' is that, in my tests at least, the effect of a comment line is that an NA appears after the immediately following line of code.  The code is reformatted.
Comment 1 John H Maindonald 2010-12-15 21:27:28 UTC
Created attachment 1159 [details]
Process with Sweave("test00")

Includes the line
\SweaveOpts{engine=R, eps=FALSE}
Comment 2 John H Maindonald 2010-12-15 21:44:03 UTC
The bug has been reproduced both under MacOS X and under Windows 
[2010-12-05 r53780, 
and R version 2.13.0 Under development (unstable), e.g., (2010-12-07 r53804)]

Attachment 1158 [details], if processed with Sweave("test01", keep.source=TRUE), generates essentially the
same result as attachment 1159 [details] when processed with Sweave("test00").

Here is the output in the first case

%% Sweave("test01", keep.source=TRUE)
%% Compare with Sweave("test01")

> print(sapply(trees, range))
> NA
     Girth Height Volume
[1,]   8.3     63   10.2
[2,]  20.6     87   77.0
> print(sapply(women, range))
> NA
     height weight
[1,]     58    115
[2,]     72    164
Comment 3 Duncan Murdoch 2010-12-17 03:26:42 UTC
I can reproduce this.  The trigger is using the name "test01", rather than the full filename "test01.Rnw".  Will fix.  In the meantime, the workaround is to use the filename with extension.
Comment 4 Duncan Murdoch 2010-12-17 04:47:22 UTC
Fixed in R-devel and R-patched, as of r53867
Comment 5 Jackie Rosen 2014-02-16 11:43:15 UTC
(spam comment removed)