Re: [R] Warning on assignment.

2009-01-15 Thread Sarah Goslee
It's the other way around. You are trying to replace 10 elements (x[i]) with 20 elements (y). R makes a "best guess" as to how you want to do that. 10 is not a multiple of 20. If you were trying to replace 20 elements with 10, then R would recycle them because 20 _is_ a multiple of 10. The safes

Re: [R] Warning on assignment.

2009-01-15 Thread Peter Dalgaard
rkevinbur...@charter.net wrote: > This was just an illustration. It is the warning message that I don't understand. The warning says "number of items to replace is not a multiple of replacement length". The way I look at it 10 is a multiple of 20. Um, with a multiplier of 0.5 ? You're trying to p

Re: [R] Warning on assignment.

2009-01-15 Thread rkevinburton
This was just an illustration. It is the warning message that I don't understand. The warning says "number of items to replace is not a multiple of replacement length". The way I look at it 10 is a multiple of 20. Kevin Sarah Goslee wrote: > The lengths are different, particularly the le

Re: [R] Warning on assignment.

2009-01-15 Thread Sarah Goslee
The lengths are different, particularly the length of subsetted x[i] > x <- 1:20 > i <- x %% 2 > 0 > y <- rep(1,20) > length(x) [1] 20 > length(i) [1] 20 > length(x[i]) [1] 10 > length(y) [1] 20 You happened to be lucky and got what you wanted, but a more reliable approach is: > x[i] <- y[i] S

[R] Warning on assignment.

2009-01-15 Thread rkevinburton
I have a question on whether a warning message is valid or if I just don't understand the process. Let me illustrate via some R code: x <- 1:20 i <- x %% 2 > 0 y <- rep(1,20) x[i] <- y Warning message: In x[i] <- y : number of items to replace is not a multiple of replacement length But it st