R/dciid.R

Defines functions dciid

Documented in dciid

dciid <-
function(x, iid = character(0))
{
    if (!is.null(dim(x))) {
        if (length(dim(x)) != 2)
            stop("'x' must have 2 dimensions")
        if (is.null(colnames(x)))
            stop("'x' must have column names")
        if (is.numeric(iid) || is.logical(iid))
            iid <- colnames(x)[iid]
        cn <- intersect(colnames(x), iid)
        if (length(cn) != length(iid))
            warning("elements of 'iid' not in colnames were dropped")
        if (!all(sapply(x, mode)[iid] == "numeric"))
            stop("'iid' columns must be numeric")
        attr(x, "iid") <- cn
    }
    class(x) <- c("dciid", class(x))
    x
}

Try the dclone package in your browser

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

dclone documentation built on July 10, 2023, 2:03 a.m.