File: show-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 (123 lines) | stat: -rw-r--r-- 4,349 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Display clustering results
setMethod("show", signature(object="APResult"),
    function(object)
    {
        cat("\nAPResult object\n")

        if (!is.finite(object@l) || !is.finite(object@it))
            stop("object is not result of an affinity propagation run; ",
                 "it is pointless to create 'APResult' objects yourself.")

        cat("\nNumber of samples     = ", object@l, "\n")
        if (length(object@sel) > 0)
        {
            cat("Number of sel samples = ", length(object@sel),
                paste("   (", round(100*length(object@sel)/object@l,1),
                      "%)\n", sep=""))
            cat("Number of sweeps      = ", object@sweeps, "\n")
        }
        cat("Number of iterations  = ", object@it, "\n")
        cat("Input preference      = ", object@p, "\n")
        cat("Sum of similarities   = ", object@dpsim, "\n")
        cat("Sum of preferences    = ", object@expref, "\n")
        cat("Net similarity        = ", object@netsim, "\n")
        cat("Number of clusters    = ", length(object@exemplars), "\n\n")

        if (length(object@exemplars) > 0)
        {
            if (length(names(object@exemplars)) == 0)
            {
                cat("Exemplars:\n")
                cat(object@exemplars, fill=TRUE, labels="  ")
                cat("Clusters:\n")

                for (i in 1:length(object@exemplars))
                {
                    cat("   Cluster ", i, ", exemplar ",
                        object@exemplars[i], ":\n", sep="")
                    cat(object@clusters[[i]], fill=TRUE, labels="     ")
                }
            }
            else
            {
                cat("Exemplars:\n")
                cat(names(object@exemplars), fill=TRUE, labels="  ")
                cat("Clusters:\n")

                for (i in 1:length(object@exemplars))
                {
                    cat("   Cluster ", i, ", exemplar ",
                        names(object@exemplars[i]), ":\n", sep="")
                    cat(names(object@clusters[[i]]), fill=TRUE, labels="     ")
                }
            }
        }
        else
        {
            cat("No clusters identified.\n")
        }
    }
)

setMethod("show", signature(object="ExClust"),
    function(object)
    {
        cat("\nExClust object\n")

        if (!is.finite(object@l))
            stop("object is not result of an exemplar-based clustering; ",
                 "it is pointless to create 'ExClust' objects yourself.")

        cat("\nNumber of samples   = ", object@l, "\n")
        cat("Number of clusters  = ", length(object@exemplars), "\n\n")

        if (length(object@exemplars) > 0)
        {
            if (length(names(object@exemplars)) == 0)
            {
                cat("Exemplars:\n")
                cat(object@exemplars, fill=TRUE, labels="  ")
                cat("Clusters:\n")

                for (i in 1:length(object@exemplars))
                {
                    cat("   Cluster ", i, ", exemplar ",
                        object@exemplars[i], ":\n", sep="")
                    cat(object@clusters[[i]], fill=TRUE, labels="     ")
                }
            }
            else
            {
                cat("Exemplars:\n")
                cat(names(object@exemplars), fill=TRUE, labels="  ")
                cat("Clusters:\n")

                for (i in 1:length(object@exemplars))
                {
                    cat("   Cluster ", i, ", exemplar ",
                        names(object@exemplars[i]), ":\n", sep="")
                    cat(names(object@clusters[[i]]), fill=TRUE, labels="     ")
                }
            }
        }
        else
        {
            cat("No clusters identified.\n")
        }
    }
)


setMethod("show", signature(object="AggExResult"),
    function(object)
    {
        cat("\nAggExResult object\n")

        if (!is.finite(object@l) || !is.finite(object@maxNoClusters))
            stop("object is not result of agglomerative clustering; ",
                 "it is pointless to create 'AggExResult' objects yourself.")

        cat("\nNumber of samples          = ", object@l, "\n")
        cat("Maximum number of clusters = ", object@maxNoClusters, "\n")
   }
)