[R] color by group in ggplot

David Winsemius dwinsemius at comcast.net
Fri May 3 22:49:48 CEST 2013


On May 3, 2013, at 1:37 PM, Ye Lin wrote:

> 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.

If I were given the task of designing a plotting system that would "decide" what to do with a categorical "x-axis" request, it would probably deliver a barplot. My guess is that you do not want that. But what do you mean by a "point" whose x-value is "A1"?

-- 

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list