File: labels-methods.R

package info (click to toggle)
r-cran-apcluster 1.4.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,744 kB
  • sloc: cpp: 1,258; ansic: 346; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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
    }
)