[R] Labels in cluster plots
Sasha Pustota
popgen at gmail.com
Fri May 26 09:30:36 CEST 2006
I'm trying to follow an example from ?clara, which plots two clusters:
> x <- rbind(cbind(rnorm(10,0,8), rnorm(10,0,8)),
cbind(rnorm(20,50,8), rnorm(20,50,8)))
> clarax <- clara(x, 2)
> clusplot(clarax)
Suppose I'd like to label these 30 observations on the plot according to a
preconceived classification, e.g. c(rep("A",15),rep("B",7),rep("C",8))
Is there a way to plot observations with these pre-specified labels?
That is, I'd like the first 15 of 'x' to be labeled as 'A', the next
seven as 'B', the next eight as 'C'.
(P.S. For principal component plots it was helpfully suggested to use
the following as an argument to the plot:
pch=c('A','B','C')[factor(c(rep("A",15),rep("B",7),rep("C",8)))]. I
can't figure out if there is a similar way here, and what is a general
way to put repeated row labels on various graphs...)
More information about the R-help
mailing list