test.data <- Harman74.cor$cov
ic.out <- ICLUST(test.data)
out.file <- file.choose(new=TRUE) #create a new file to write the plot commands to
ICLUST.graph(ic.out,out.file)
now go to graphviz (outside of R) and open the out.file you created
print(ic.out,digits=2)
#test.data <- Harman74.cor$cov
#my.iclust <- ICLUST(test.data)
#ICLUST.graph(my.iclust)
#
#
#digraph ICLUST {
# rankdir=RL;
# size="8,8";
# node [fontname="Helvetica" fontsize=14 shape=box, width=2];
# edge [fontname="Helvetica" fontsize=12];
# label = "ICLUST";
# fontsize=20;
#V1 [label = VisualPerception];
#V2 [label = Cubes];
#V3 [label = PaperFormBoard];
#V4 [label = Flags];
#V5 [label = GeneralInformation];
#V6 [label = PargraphComprehension];
#V7 [label = SentenceCompletion];
#V8 [label = WordClassification];
#V9 [label = WordMeaning];
#V10 [label = Addition];
#V11 [label = Code];
#V12 [label = CountingDots];
#V13 [label = StraightCurvedCapitals];
#V14 [label = WordRecognition];
#V15 [label = NumberRecognition];
#V16 [label = FigureRecognition];
#V17 [label = ObjectNumber];
#V18 [label = NumberFigure];
#V19 [label = FigureWord];
#V20 [label = Deduction];
#V21 [label = NumericalPuzzles];
#V22 [label = ProblemReasoning];
#V23 [label = SeriesCompletion];
#V24 [label = ArithmeticProblems];
#node [shape=ellipse, width ="1"];
#C1-> V9 [ label = 0.78 ];
#C1-> V5 [ label = 0.78 ];
#C2-> V12 [ label = 0.66 ];
#C2-> V10 [ label = 0.66 ];
#C3-> V18 [ label = 0.53 ];
#C3-> V17 [ label = 0.53 ];
#C4-> V23 [ label = 0.59 ];
#C4-> V20 [ label = 0.59 ];
#C5-> V13 [ label = 0.61 ];
#C5-> V11 [ label = 0.61 ];
#C6-> V7 [ label = 0.78 ];
#C6-> V6 [ label = 0.78 ];
#C7-> V4 [ label = 0.55 ];
#C7-> V1 [ label = 0.55 ];
#C8-> V16 [ label = 0.5 ];
#C8-> V14 [ label = 0.49 ];
#C9-> C1 [ label = 0.86 ];
#C9-> C6 [ label = 0.86 ];
#C10-> C4 [ label = 0.71 ];
#C10-> V22 [ label = 0.62 ];
#C11-> V21 [ label = 0.56 ];
#C11-> V24 [ label = 0.58 ];
#C12-> C10 [ label = 0.76 ];
#C12-> C11 [ label = 0.67 ];
#C13-> C8 [ label = 0.61 ];
#C13-> V15 [ label = 0.49 ];
#C14-> C2 [ label = 0.74 ];
#C14-> C5 [ label = 0.72 ];
#C15-> V3 [ label = 0.48 ];
#C15-> C7 [ label = 0.65 ];
#C16-> V19 [ label = 0.48 ];
#C16-> C3 [ label = 0.64 ];
#C17-> V8 [ label = 0.62 ];
#C17-> C12 [ label = 0.8 ];
#C18-> C17 [ label = 0.82 ];
#C18-> C15 [ label = 0.68 ];
#C19-> C16 [ label = 0.66 ];
#C19-> C13 [ label = 0.65 ];
#C20-> C19 [ label = 0.72 ];
#C20-> C18 [ label = 0.83 ];
#C21-> C20 [ label = 0.87 ];
#C21-> C9 [ label = 0.76 ];
#C22-> 0 [ label = 0 ];
#C22-> 0 [ label = 0 ];
#C23-> 0 [ label = 0 ];
#C23-> 0 [ label = 0 ];
#C1 [label = "C1\n alpha= 0.84\n beta= 0.84\nN= 2"] ;
#C2 [label = "C2\n alpha= 0.74\n beta= 0.74\nN= 2"] ;
#C3 [label = "C3\n alpha= 0.62\n beta= 0.62\nN= 2"] ;
#C4 [label = "C4\n alpha= 0.67\n beta= 0.67\nN= 2"] ;
#C5 [label = "C5\n alpha= 0.7\n beta= 0.7\nN= 2"] ;
#C6 [label = "C6\n alpha= 0.84\n beta= 0.84\nN= 2"] ;
#C7 [label = "C7\n alpha= 0.64\n beta= 0.64\nN= 2"] ;
#C8 [label = "C8\n alpha= 0.58\n beta= 0.58\nN= 2"] ;
#C9 [label = "C9\n alpha= 0.9\n beta= 0.87\nN= 4"] ;
#C10 [label = "C10\n alpha= 0.74\n beta= 0.71\nN= 3"] ;
#C11 [label = "C11\n alpha= 0.62\n beta= 0.62\nN= 2"] ;
#C12 [label = "C12\n alpha= 0.79\n beta= 0.74\nN= 5"] ;
#C13 [label = "C13\n alpha= 0.64\n beta= 0.59\nN= 3"] ;
#C14 [label = "C14\n alpha= 0.79\n beta= 0.74\nN= 4"] ;
#C15 [label = "C15\n alpha= 0.66\n beta= 0.58\nN= 3"] ;
#C16 [label = "C16\n alpha= 0.65\n beta= 0.57\nN= 3"] ;
#C17 [label = "C17\n alpha= 0.81\n beta= 0.71\nN= 6"] ;
#C18 [label = "C18\n alpha= 0.84\n beta= 0.75\nN= 9"] ;
#C19 [label = "C19\n alpha= 0.74\n beta= 0.65\nN= 6"] ;
#C20 [label = "C20\n alpha= 0.87\n beta= 0.74\nN= 15"] ;
#C21 [label = "C21\n alpha= 0.9\n beta= 0.77\nN= 19"] ;
#C22 [label = "C22\n alpha= 0\n beta= 0\nN= 0"] ;
#C23 [label = "C23\n alpha= 0\n beta= 0\nN= 0"] ;
#{ rank=same;
#V1;V2;V3;V4;V5;V6;V7;V8;V9;V10;V11;V12;V13;V14;V15;V16;V17;V18;V19;V20;V21;V22;V23;V24;}}
#
#copy the above output to Graphviz and draw it
#see \url{http://personality-project.org/r/r.ICLUST.html} for an example.
## The function is currently defined as
function(ic.results, out.file,short=FALSE,
size=c(8,8), node.font=c("Helvetica", 14),
edge.font=c("Helvetica", 12), rank.direction="RL", digits=2,title="ICLUST", ...){
if(!missing(out.file)){
out <- file(out.file, "w")
on.exit(close(out))
}
else out <- stdout()
results <- ic.results$results
var.labels <- rownames(ic.results$loadings)
clusters <- ic.results$clusters
if(length(clusters)==length(var.labels) ){clusters <- as.matrix(clusters)}
num <- nrow(results)
if (short) {var.labels <- paste("V",1:nrow(var.labels),sep="")}
rank.direction <- match.arg(rank.direction)
#first some basic setup parameters
cat( file=out,paste('digraph ICLUST', ' {<n>', sep=""))
cat(file=out, paste(' rankdir=', rank.direction, ';<n>', sep=""))
cat(file=out, paste(' size="',size[1],',',size[2],'";<n>', sep=""))
cat(file=out, paste(' node [fontname="', node.font[1],
'" fontsize=', node.font[2], ' shape=box, width=2];<n>', sep=""))
cat(file=out, paste(' edge [fontname="', edge.font[1],
'" fontsize=', edge.font[2], '];<n>', sep=""))
cat(file=out, paste(' label = "' ,title,'";
fontsize=20;<n>', sep=""))
#create the items as boxes
#add the sign from the clusters
num.var <- nrow(results)+1 #how many variables?
for (i in 1:num.var) { if (max(clusters[i,]) > 0 ) {
cat(file=out,paste('V',i,' [label = "',var.labels[i], '"];<n>', sep=""))</n> else {
cat(file=out,paste('V',i,' [label = "-',var.labels[i], '"];<n>', sep=""))</n>
}
#show the cluster structure with ellipses
cat(file=out,paste('node [shape=ellipse, width ="1"];<n>', sep=""))
for (i in 1:num) {if(results[i,1]>0) { #avoid printing null results
cat(file=out,paste(row.names(results)[i], '-> ', results[i,1],
' [ label = ',round(results[i,"r1"],digits),' ];<n>', sep=""))
cat(file=out,paste(row.names(results)[i], '-> ', results[i,2],
' [ label = ',round(results[i,"r2"],digits),' ];<n>', sep=""))</n></n>
#label the clusters with alpha and beta
for (i in 1:num) {if(results[i,1]>0) { #don't print blank results
cat(file=out,paste(row.names(results)[i], ' [label = "',row.names(results)[i],
'\n alpha= ',round(results[i,"alpha"],digits),'\n beta= ' ,
round(results[i,"beta"],digits),'\nN= ',results[i,"size"], '"] ;<n>', sep=""))</n>}
#keep the boxes all at the same rank (presumably the left side)
cat(file=out, paste('{ rank=same;<n>', sep=""))
for (i in 1:num.var) { cat(file=out,paste('V',i,';', sep=""))
}
cat(file=out, paste('</n>}', sep="")) # we are finished
} # end of ICLUST.graph
}
<keyword>multivariate</keyword><keyword>cluster</keyword></n></n></n></n></n></n></n>
Run the code above in your browser using DataLab