It's done -- in any case -- just once, after the loop is finished. Remember
that "hash" sign is not just that, it's used for comments! Why should it be
surprising that your code will be doing something else when you comment out
(i.e. skip) some parts of it? Try this simplified example:

sample_times <- 1:5
first <- paste(# sample_times, # HERE!!!!
       "something", "\n")

... and compare that with

second <- paste(sample_times, # HERE!!!!
       "something", "\n")

You have just one element in `first` but 5 in `second` -- that's because you
have a vector with length 5 in `second`; and the same happens in your
example. No bugs involved.

Best regards,

KK


On Sun, Jan 11, 2009 at 12:50 PM, Oliver Bandel
<oli...@first.in-berlin.de>wrote:

> Hello,
>
>
> here I have some code, which behaves quite strange, IMHO.
> There is a "res.txt" which will be collected before printing it.
>
> There is a paste-statement, which has a comment at the end of the line,
> which is this one: "# !!!!!HERE!!!!!".
>
> If you throw out the first hash-mark "#" on that line,
> the printout behaves like if it is done for each of the
> for-loop iterations. If the hash mark will not be thrown out,
> it behaves, as I would expect: done *once*, after the loop is finished.
>
> I'm using "R version 2.7.1 (2008-06-23)" on Debian.
>
> Can you please show me, what is going wrong here?
>
>
> The code is not much, but too long (too many lines and
> lines too long) for pasting it here, so I have placed
> it here:
>
>  http://www.first.in-berlin.de/trybug.R
>
> Can you show me, why the behaviour differs so much,
> when just removing that "#" ?!
>
> Ciao,
>  Oliver
>
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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