[R] struggling to plot subgroups

hadley wickham h.wickham at gmail.com
Sun Nov 5 06:37:29 CET 2006


On 11/4/06, Sumitrajit Dhar <s-dhar at northwestern.edu> wrote:
> Hi Folks,
>
> I have data that looks like this:
>
> freq            gender          xBar
> 1000    m                       2.32
> 1000    f                       3.22
> 2000    m                       4.32
> 2000    f                       4.53
> 3000    m                       3.21
> 3000    f                       3.44
> 4000    m                       4.11
> 4000    f                       3.99
>
> I want to plot two lines (with symbols) for the two groups "m" and
> "f". I have tried the following:

This is pretty easy with ggplot.  Something like:

install.packages("ggplot")
library(ggplot)
qplot(freq, xBar, data=my.data.frame, colour=gender, id=gender,
type=c("point","line"))

should do what you want.

Hadley



More information about the R-help mailing list