R/labels-methods.R

# convert clustering result to label vector
setMethod("labels", signature(object="ExClust"),
    function(object, type="names")
    {
        if (type == "names")
        {
            if (length(names(object@idx)) == 0)
                stop("no names available, use other type")
            else
                out <- names(object@idx)
        }
        else if (type == "exemplars")
            out <- object@idx
        else if (type == "enum")
        {
            out <- array(dim=object@l)

            for (i in 1:length(object@exemplars))
                out[which(object@idx == object@exemplars[i])] <- i
        }
        else
            stop("type '", type, "' unknown")

        attributes(out) <- NULL

        out
    }
)

Try the apcluster package in your browser

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

apcluster documentation built on Sept. 20, 2023, 1:06 a.m.