[Rd] Bug in Sweave? -- scoping problem? (PR#8615)
Friedrich.Leisch@tuwien.ac.at
Friedrich.Leisch at tuwien.ac.at
Mon Feb 20 09:37:40 CET 2006
I will add it to the FAQ.
fritz
>>>>> On Sun, 19 Feb 2006 08:42:09 -0500,
>>>>> Duncan Murdoch (DM) wrote:
[...]
> Code in chunks that produce pictures is executed several times.
> First, to produce the output in the text. And then once more
> for *each* format in which the figure has to be produced. I.e.,
> if you want a PDF and a PostScript version of the figure, the
> code is executed a total of three times.
> Thanks, that's what caught me. Is that a quote from the discussion, or
> from the docs somewhere? It makes sense in hindsight, but it's not
> obvious ahead of time, so it should be stated fairly prominently in the
> docs.
> Duncan Murdoch
>>
>> All instances of this feature reported so far involved commands that
>> produced random numbers and the poster was surprised that the output
>> in the text and the figures differed (and that the two figures were
>> different).
>>
>> In your case the first execution of the code assigns the names to
>> partytotal, sorts partytotal and produces the data. On the next
>> execution, when the picture is produced, partytotal is already sorted
>> but you reassign the names. Then the partytotal is sorted again and
>> the plot is produced. But that re-assigning of names lead to the
>> disconnect between values and names.
>>
>> Hope this helps.
>>
>> Cheers,
>>
>> Berwin
>>
>> ========================== Full address ============================
>> Berwin A Turlach Tel.: +61 (8) 6488 3338 (secr)
>> School of Mathematics and Statistics +61 (8) 6488 3383 (self)
>> The University of Western Australia FAX : +61 (8) 6488 1028
>> 35 Stirling Highway
>> Crawley WA 6009 e-mail: berwin at maths.uwa.edu.au
>> Australia http://www.maths.uwa.edu.au/~berwin
More information about the R-devel
mailing list