Match .3 in a sequence
Petr Savicky wrote:
On Mon, Mar 16, 2009 at 06:36:53AM -0700, Daniel Murphy wrote:
Hello:I am trying to match the value 0.3 in the sequence seq(.2,.3). I get
0.3 %in% seq(from=.2,to=.3)
[1] FALSE
As others already pointed out, you should use seq(from=0.2,to=0.3,by=0.1) to get 0.3 in the sequence. In order to get correct %in%, it is also possible to use round(), for example
> 0.3 %in% round(seq(from=0.2,to=0.3,by=0.1),digits=1)
[1] TRUE
half-jokingly, there's another solution, which avoids rounding:
0.3 %in% (seq(0.4, 0.5, 0.1)-0.2)
# TRUE
vQ