Stack Exchange
Getting number of micro cluster from Clustree in R
I am unable to retrieve number of microclusters from Clustree. Following is the code:
library(streamMOA)
data <- read.csv("data.csv", sep = ",", header = TRUE)
stream <- DSD_Memory(data)
clustree <- DSC_ClusTree(maxHeight = 3)
reset_stream(stream)
update(clustree, stream, 200)

Now if print clustree object, I get:
print(clustree)

ClusTree
Class: DSC_ClusTree, DSC_Micro, DSC_MOA, DSC 
Number of micro-clusters: 20 

However, clustree&description, clustree$options or clustree&javaObj don't give number of micro clusters. Any help?

One way to do is to capture the output of print and process the string:
str <- capture.output(print(clustree))
mic_clus <- as.numeric(unlist(strsplit(str[3], split=' ', fixed=TRUE))[4])

a_greater_than_five <- ifelse(a > 5, TRUE, FALSE)
