Learn R Programming

CORE (version 1.2)

interval.schedule:

Usage

interval.schedule(v)

Arguments

v

Value

    Examples

    Run this code
    ##---- 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 (v) 
    {
        if (!("start" %in% dimnames(v)[[2]]) | !("end" %in% dimnames(v)[[2]]) | 
            length(dim(v)) != 2) 
            stop("interval.schedule: incorrect form of input
    ")
        lv <- nrow(v)
        if (sum(sort(v[, "start"]) == v[, "start"]) != lv) 
            stop("interval.schedule: input incorrectly ordered
    ")
        unsch <- lv
        schedule <- 0
        vsched <- rep(0, lv)
        while (unsch > 0) {
            schedule <- schedule + 1
            vsched[cummax(v[, "end"] * (vsched == 0)) == v[, "end"]] <- schedule
            unsch <- sum(vsched == 0)
        }
        return(vsched)
      }

    Run the code above in your browser using DataLab