, , . R .
cuts vals :
cuts <- c( -Inf, -1.793, -1.304, -0.326, 0.625, 1.630, 2.119 )
vals <- c( 0, 0.454, 0, 0.632, 0, 0.227, 0 )
findInterval x :
fx <- vals[findInterval(x, c(-Inf, cuts))]
, , vals, , list, .
Alternatively, since this function is stepwise, you can use stepfun:
f <- stepfun(cuts[-1], vals)
fx <- f(x)
Then you can also use good construction methods stepfun.
source
share