[R] Sweave Executes Package Functions Twice
Dario Strbenac
D.Strbenac at garvan.org.au
Fri Apr 15 13:00:20 CEST 2011
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.
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
More information about the R-help
mailing list