Re: [R] problem in for loop

2011-02-24 Thread Jeff Newmiller
Notice that >mone-3 [1] -8.881784e-16 on my machine so, no, mone is actually less than 3, which truncates to 2. This is an overcomplicated version of R FAQ 7.31, which is mentioned in the posting guide referenced at the end of every R-help message. --

Re: [R] problem in for loop

2011-02-24 Thread Sarah Goslee
You've fallen afoul of rounding error, FAQ 7.31 I believe, > rnorm(3, 0, 1) [1] -2.0903756 -0.9314351 0.1477768 but > rnorm(mone, 0, 1) [1] -0.8695359 -0.5429294 because mone is not actually three, but on my linux system a bit less. > mone == 3 [1] FALSE > mone < 3 [1] TRUE You could try >

Re: [R] problem in for loop

2011-02-24 Thread Ivan Calandra
Hi, It's FAQ 7.31 Try this: mone <- round(m-mzero) HTH, Ivan Le 2/24/2011 18:31, li li a écrit : Hi all. I was having some trouble with a for loop and I found the problem is the following. Does anyone have some idea why I got the following R result? Since mone is equal to 3, why mu1 on

[R] problem in for loop

2011-02-24 Thread li li
Hi all. I was having some trouble with a for loop and I found the problem is the following. Does anyone have some idea why I got the following R result? Since mone is equal to 3, why mu1 only have 2 components? library(MASS) > p0 <- seq(0.1, 0.9,by=0.1) > m <- 10 > > > p0 <- p0[7] > > ## da