From Waclaw.Marcin.Kusnierczyk at idi.ntnu.no  Mon Mar 16 21:19:58 2009
From: Waclaw.Marcin.Kusnierczyk at idi.ntnu.no (Wacek Kusnierczyk)
Date: Mon, 16 Mar 2009 21:19:58 +0100
Subject: [Rd] Match .3 in a sequence
In-Reply-To: <20090316164154.GB15686@cs.cas.cz>
References: <48f8cced0903160636k112500f6k4b8d46c1ac775d89@mail.gmail.com>
	<20090316164154.GB15686@cs.cas.cz>
Message-ID: <49BEB46E.9090601@idi.ntnu.no>

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



[Rd] Match .3 in a sequence
Wacek Kusnierczyk