[R] how to get the position of a vector-value

2008-07-29 Thread Jörg Groß
I am searching for a way to get nearest position of a number in a vector from a search-value. So perhaps if I have this vector: 1.0 1.2 1.4 1.6 1.8 2.0 I want to get the position of a special number. with match(1.4 ,x), I get 3 for position three. But now I want the nearest number

Re: [R] how to get the position of a vector-value

2008-07-29 Thread jim holtman
?findInterval x - c(1.0,1.2,1.4,1.6,1.8,2.0) findInterval(1.4,x) [1] 3 findInterval(1.5,x) [1] 3 findInterval(10,x) [1] 6 On Tue, Jul 29, 2008 at 8:32 PM, Jörg Groß [EMAIL PROTECTED] wrote: I am searching for a way to get nearest position of a number in a vector from a search-value. So