[R] screen if a value is within range

Robert Baer rbaer at atsu.edu
Sat Dec 1 18:04:18 CET 2012


On 12/1/2012 10:50 AM, Andras Farkas wrote:
> Dear all,
>   
> could you please give me some pointers on how I could make R screen for a value if it falls within a certain range?
> I looked at the subset function, but is not doing it, perhaps because I only have 1 value to screen?
>   
> aptreciate the input
>   
> ex:
> a <-16.5
> I would like to screen to see if a is within the range of 15 to 20, (which it is:-)), and I would like the code to return a value of 1 if a is within the specified range or 0 if it is not.
>   
> Apreciate the insights,
>   
> Andras
> 	[[alternative HTML version deleted]]
a = 16.5
ans = (a >= 15 & a <= 20)
ans
[1] TRUE

Rob




More information about the R-help mailing list