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
I suspect your example code is too long & complicated for anyone to bother attempting to help you. Try simplifying it to just a few lines; I've found that the simplification process itself often leads me to the solution to my own problem. On Sun, Jan 11, 2009 at 6:50 AM, Oliver Bandel <oliver@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. >-- Mike Lawrence Graduate Student Department of Psychology Dalhousie University www.thatmike.com Looking to arrange a meeting? Check my public calendar: http://www.thatmike.com/mikes-public-calendar ~ Certainty is folly... I think. ~ [[alternative HTML version deleted]]
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 <oliver@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]]
Seemingly Similar Threads
- Parse-Error creates strange function calls (completely different printouts) (PR#13436)
- Parse-Error creates strange function calls (completely different (PR#13438)
- sprintf does not fill with "0"?!
- rgl-snapshot failed (err-msg: "failed")
- From time-strings to Unix-Epoche-time?