Re: [R] Colour clusters in a 2d plot

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Mon, 07 Jul 2008 14:31:49 -0400

Dear Josep,

Does it do the work for you?

# Example data
set.seed(123)
mydata=data.frame(c1=rnorm(100),c2=rnorm(100),cluster=sample(1:10,100,replace=TRUE)) attach(mydata)

# Plot
plot(c1,c2,col=cluster,pch=16,xlab="Your legend here",ylab="Your legend here")

HTH, Jorge

On Mon, Jul 7, 2008 at 1:51 PM, Josep Maria Campanera Alsina < campaxic_at_gmail.com> wrote:

> R experts,
>
> I have three columns. c1 and c2 are numeric variables whereas c3 are the
> clusters classes (nominal variable, 10 different: cluster1, cluster2,
> cluster3, cluster4, cluster5 ....). I'd like to plot c1 against c2 (easy!)
> in a 2D plot and put different color depending to the cluster class
> automatically regardless the number of clusters.
>
> Could anyone give a hand?
>
> Josep Maria,
>
>
> matrix <- read.table(fileName, header=TRUE, sep=",")
> c1<-matrix[,1]
> c2<-matrix[,2]
> c3<-matrix[,3]
> plot(c1,c2) ????? what else?
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 07 Jul 2008 - 18:36:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Jul 2008 - 19:31:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive