R/convertSUSTAIN.R

Defines functions convertSUSTAIN

Documented in convertSUSTAIN

convertSUSTAIN <- function(input, dims) {
    out <- matrix(0, nrow = nrow(input), ncol = sum(dims))
    places <- t(apply(input, 1,
                      function (x) x + (c(0, cumsum(dims)[-length(dims)]))))
    for (i in 1:nrow(out)) {
        out[i, ][places[i, ]] <- 1
    }
    colnames(out) <- NULL
    return(out)
}

Try the catlearn package in your browser

Any scripts or data that you put into this service are public.

catlearn documentation built on March 26, 2022, 1:07 a.m.