Thanks A.K !!!!
I also add "shape=variable" so that it is much easier to tell two variables
by color +shape



On Fri, May 3, 2013 at 2:14 PM, arun <smartpink111@yahoo.com> wrote:

> HI,
> May be this helps:
>
> dat1<- read.table(text="
> ID    Var1      Var2    Group
> A1        1            1            BB
> A2        1          2            AA
> B1          2          1            CC
> B2        1            3            DD
> C1          1            2            EE
> ",sep="",header=TRUE)
> library(reshape2)
> dat2<-melt(dat1,id.var=c("ID","Group"))
> library(ggplot2)
> ggplot(dat2,aes(x=ID,y=value,group=Group,colour=Group))+geom_point()
> A.K.
>
>
>
> ----- Original Message -----
> From: Ye Lin <yelin@lbl.gov>
> To: R help <r-help@r-project.org>
> Cc:
> Sent: Friday, May 3, 2013 4:37 PM
> Subject: [R] color by group in ggplot
>
> Hey,
>
> I have a dataset like this:
>
> ID     Var1       Var2     Group
> A1         1            1            BB
> A2         1           2            AA
> B1          2          1             CC
> B2         1            3            DD
> C1          1            2            EE
>
> I would like to plot the points of Var1 and Var2, use "ID" as X-axis, but
> color the points by "Group". I can only manage to color the points by "ID"
> after transform the dataset to "tall" using "reshape" package.
>
> Thanks for your help!
>
>     [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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]]

