1 | resdepth(x, res)
|
x |
|
res |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, res)
{
if (!is.vector(x))
stop("x should be a vector")
n <- length(x)
if (n < 2)
stop("you need at least two observations")
flag = is.na(res)
x = x[!flag]
res[!flag]
xord = order(x)
x = x[xord]
res = res[xord]
posres <- res >= 0
negres <- res <= 0
lplus <- cumsum(posres)
rplus <- lplus[n] - lplus
lmin <- cumsum(negres)
rmin <- lmin[n] - lmin
depth <- pmin(lplus + rmin, rplus + lmin)
min(depth)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.