R/cscl.R

cscl <-
function (x, scl, sep) 
{
    ifelse(missing(sep) == TRUE, sep <- "_", NA)
    lvl <- attr(scl, "names")
    dx <- data.frame(matrix(NA, ncol = ncol(x) * ncol(scl), nrow = 0))
    for (i in seq_len(nrow(x))) {
        tmp <- vector()
        for (j in seq_len(ncol(x))) {
            tmp <- c(tmp, as.vector(unlist(scl[which(x[i, j] == 
                lvl), ])))
        }
        rm(j)
        dx <- rbind(dx, tmp)
    }
    rm(i)
    rownames(dx) <- rownames(x)
    colnames(dx) <- paste0(rep(colnames(x), each = length(lvl)), 
        sep, lvl)
    dx
}

Try the multiplex package in your browser

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

multiplex documentation built on Nov. 16, 2023, 5:08 p.m.