On 15/04/2011 7:00 AM, Dario Strbenac wrote:
Hi,

I've got something strange going on. I'm trying to compile a vignette using 
Sweave("vignette.Rnw"), and in the first code chunk that illustrates an 
example, I noticed from the output text I have inside the function, that it is running it 
twice, because the sequence of message() statements is output on screen twice, and takes 
twice as long to do.

e.g.
Processing sample 1
Processing sample 2
Processing sample 3
Processing sample 1
Processing sample 2
Processing sample 3

If I open up a new R session, and copy and paste the lines of code from the 
.Rnw one by one, the function isn't called twice - only one complete set of 
progress outputs show.

This is standard behaviour for a chunk that is drawing figures. The solution is to *only* draw the figure in such a chunk, do all your computation in other chunks.

In version 2.14.0 in the fall, this will no longer be the default behaviour. Perhaps it will be possible to suppress the multiple runs before then, but I think it is unlikely that the default will change.

Duncan Murdoch

I tried using debug() to get more of an idea of what was happening. The function is called enrichmentPlot, so I 
did debug(enrichmentPlot), then Sweave("vignette.Rnw"). Execution pauses when it gets to the right 
code chunk, then I type in "n" at the Browse[2]>  prompt, but I don't get any output from debug, 
like "debugging in:", but it runs for a while and I get all of the messages from within my function, 
then execution pauses again. But just before it pauses I get the debug output :

debugging in: enrichmentPlot(samples.list, 300)
debug: standardGeneric("enrichmentPlot")
Browse[2]>

Then I enter "n", and it runs the same code all over again.

...       ... # Same progress outputs from inside my function.
exiting from: enrichmentPlot(samples.list, 300)

I have the current 2.13.0 version of R. I'm sure I've done something wrong, I 
just can't figure out what. Thanks for any help.

--------------------------------------
Dario Strbenac
Research Assistant
Cancer Epigenetics
Garvan Institute of Medical Research
Darlinghurst NSW 2010
Australia

______________________________________________
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.

______________________________________________
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.

Reply via email to