Hi:
Do you want the N points in the vector closest to a fixed point? If
so, then try this:
f <- function(vec, center, nselect) {
d <- (vec - center)^2
vec[order(d)][1:nselect]
}
v <- rnorm(1000)
f(v, 0, 10)# select the ten points in v closest to zero
Your goal is subject to multip
On Jul 8, 2011, at 3:16 PM, Nipesh Bajaj wrote:
Hi there, given a numeric vector, I can select numbers within a
specific range. However presently, I have something related but
different problem. Suppose I have a numeric vector. Now take an
arbitrary number. Goal to to chose a specific subset wi
Hi there, given a numeric vector, I can select numbers within a
specific range. However presently, I have something related but
different problem. Suppose I have a numeric vector. Now take an
arbitrary number. Goal to to chose a specific subset with a given
length, from that given vector, so that t
3 matches
Mail list logo