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
}
)
|