Message-ID: <f8e6ff050809121604n32d0d0bcy5b55aa96d79a1aa2@mail.gmail.com>
Date: 2008-09-12T23:04:31Z
From: Hadley Wickham
Subject: Scatterplot with data grouped by color
In-Reply-To: <32699B64-B765-46AD-81F9-C3747B9271D9@mit.edu>
On Fri, Sep 12, 2008 at 5:29 PM, Amanda Young <amandag at mit.edu> wrote:
> Hi,
> I am a complete R rookie so this question is probably really simple
> but I haven't found an answer on the web that I can understand.
>
> My data frame has 3 columns, A, B and C. A and B have numbers (about
> 8000 rows), C is a factor which is either true or false. So I can
> plot A vs B with plot(dataframe$A, dataframe$B). However, I would
> like the points to be different colors depending on whether C is True
> or False. Even better, if C had more than 2 groups, like group 1,2,3
> can I make all 3 different colors, etc? It would be really helpful to
> give an example using my scenario since I have a lot of trouble
> understanding other examples on the web because the data is not set
> up like my data.
install.packages("ggplot2")
library(ggplot2)
qplot(A, B, data = dataframe, color = C)
That will also automatically draw a legend for you. See
http://had.co.nz/ggplot2 for more info.
Hadley
--
http://had.co.nz/