1 | ins.sort.c(vec, sor.mat, sor.mat.sz, n)
|
vec |
|
sor.mat |
|
sor.mat.sz |
|
n |
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 28 | ##---- 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 (vec, sor.mat, sor.mat.sz, n)
{
r.min <- 1
r.max <- sor.mat.sz
tau <- vec[n]
if (tau > sor.mat[r.max, n]) {
r.min <- r.max <- sor.mat.sz + 1
}
else {
while (r.max > r.min) {
r.mid <- floor(0.5 * (r.max + r.min))
if (tau <= sor.mat[r.mid, n]) {
r.max <- r.mid
}
else {
r.min <- r.mid + 1
}
}
}
return(rbind(sor.mat[seq_len(r.min - 1), , drop = FALSE],
vec, sor.mat[seq_len(sor.mat.sz - r.max + 1) + r.max -
1, , drop = FALSE]))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.