Skip to content
Prev 117846 / 398498 Next

if statement

My solutions are usually too baroque, but does this do what you want?

x <- rnorm(100)
quants <- quantile(x, c(.3, .7))
Case <- rep(2, length(x)) # 2 lies in the middle of the distribution
Case[x <= quants[1]] <- 0
Case[x >= quants[2]] <- 1
Case

Cheers,

Simon.
On Mon, 2007-06-11 at 15:14 -0700, Jiong Zhang, PhD wrote: