##---- 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 (vstart, vend, wstart, wend)
{
lw <- length(wstart)
lv <- length(vstart)
z <- cbind(c(vstart, wstart), c(1:lv, rep(0, lw)), c(rep(0,
lv), 1:lw))
z <- z[order(z[, 1]), ]
startbeforestart <- cummax(z[, 2])[order(z[, 3])][sort(z[,
3]) != 0]
z <- cbind(c(wend, vend), c(rep((lv + 1), lw), 1:lv), c(1:lw,
rep(0, lv)))
z <- z[order(z[, 1]), ]
endafterend <- rev(cummin(rev(z[, 2])))[order(z[, 3])][sort(z[,
3]) != 0]
return(cbind(endafterend, startbeforestart))
}
Run the code above in your browser using DataLab