[R] Funny result from rep(...) procedure

2010-02-18 Thread dkStevens
I'm observing odd behavior of the rep(...) procedure when using variables as parameters in a loop. Here's a simple loop on a vector 'branches' that is c(5,6,5,5,5). The statement in question is print(c(ni,rep(i,times=ni))) that works properly first time through the loop but the second

Re: [R] Funny result from rep(...) procedure

2010-02-18 Thread Erik Iverson
Cannot reproduce, what is branches? If you can narrow it down to a commented, minimal, self-contained, reproducible example, you're far more likely to get help from the list. dkStevens wrote: I'm observing odd behavior of the rep(...) procedure when using variables as parameters in a loop.

Re: [R] Funny result from rep(...) procedure

2010-02-18 Thread Erik Iverson
Erik Iverson wrote: Cannot reproduce, what is branches? If you can narrow it down to a commented, minimal, self-contained, reproducible example, you're far more likely to get help from the list. My blinded guess though, is something to do with FAQ 7.31.

Re: [R] Funny result from rep(...) procedure

2010-02-18 Thread Eik Vettorazzi
Sorry, not reproducible. This works for me (as expected): branches-c(5,6) iInd = 1 for(i in 1:length(branches)) { print((1:branches[i])+iInd-1) # iInd is a position shift of the index ni = branches[i] print(i) print(ni) print(c(ni,rep(i,times=ni))) # ... some interesting other

Re: [R] Funny result from rep(...) procedure

2010-02-18 Thread Henrik Bengtsson
On Thu, Feb 18, 2010 at 7:15 PM, Erik Iverson er...@ccbr.umn.edu wrote: Erik Iverson wrote: Cannot reproduce, what is branches?  If you can narrow it down to a commented, minimal, self-contained, reproducible example, you're far more likely to get help from the list. My blinded guess

Re: [R] Funny result from rep(...) procedure

2010-02-18 Thread dkStevens
That's what I did. 'branches' was shown at the top. branches = c(5,6,5,5,5) I tested this. When I copy and paste into R 10.0 I get the result in the post. Perhaps I should reinstall R. I guess I don't see how much more narrow I can get than this. i iInd = 1 for(i in

Re: [R] Funny result from rep(...) procedure

2010-02-18 Thread dkStevens
I could send the entire bit of code but I was hoping that someone would recognize the issue from past experience. I may be an artifact of other parts of the code. I observed the problem in a larger context and cut out all that you see below. The comments were next to the results to clarify.

Re: [R] Funny result from rep(...) procedure

2010-02-18 Thread Henrik Bengtsson
What does print(as.integer(branches)) give? That is what rep() uses. /H On Thu, Feb 18, 2010 at 7:49 PM, dkStevens david.stev...@usu.edu wrote: I could send the entire bit of code but I was hoping that someone would recognize the issue from past experience. I may be an artifact of other