Hi, Can anyone explain what is going on...!? For a vector "x=seq(min,max,0.01)", when generating sub-vector "a" based on a starting value "st", things go as expected as long as "st" is not too close to the beginning of "x". For example, if x starts at -5 and increments by 0.01, whenever I try to generate the sub-vector "a" (as below) with a starting value of 0.49 or less it does not generate the expected output: The initial value of "a" is wrong. Thanks in advance for any clarity you can shed. Gary
...(please see two versions of code below).... #THIS WORKS...(st > -4.9) min = -5; max = 1; x=seq(min,max,0.01) st= -4.8 ; end= 0 a=x[((st-min)/0.01+1):((end-min)/0.01+1)] n=(st-min)/0.01+1 #compare a[1:10]; c(x[n:(n+9)]) #test... n x[1:n]; x[n] ### x[n]== x[1:n][n] ; As expected ########################################################## # BUT THIS IS WEIRD!!...(st <= -4.9) st= -4.90 ; end= 0 ### -> BUG in generation of a!! a=x[((st-min)/0.01+1):((end-min)/0.01+1)]; n=(st-min)/0.01+1 #compare a[1:10]; c(x[n:(n+9)]) #test n x[1:n]; x[n] ### NOW x[n] != x[1:n][n] !!?? What is going on!? -- View this message in context: http://r.789695.n4.nabble.com/Strange-subvector-output-x-n-x-1-n-n-tp4682526.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.