[R] how to plot a data by different group

Ista Zahn istazahn at gmail.com
Mon Oct 12 23:06:41 CEST 2009


Hi Catherine,
Assuming your variables are in a dataframe called myData, some
variation of the following may be what you want:

library(ggplot2)
myData.m <- melt(myData, measure.vars=c("Y1", "Y2"))
qplot(X, value, colour=variable, shape=groupf3,
facets=groupf1~groupf2, geom="point", data=myData.m)

-Ista

On Mon, Oct 12, 2009 at 4:36 PM, catherineLF <cathelf at hotmail.com> wrote:
>
> Dear everyone,
> sorry to bother you. I have a big data, suppose it has 200 groups and each
> group has 100 data. So the data have 20000 observations in total. The
> variables are
> groupf1  groupf2 groupf3  X  Y1  Y2
> 1                 1            1   1 0.5  0.5
>
> ....
> groupf1, groupf2 and groupf3 are defining the 200 groups.
>
> I want to make 200 graphs for each group. For each group, graph Y1 and Y2 vs
> X.
> Is there any easy way to do that?
>
> Thank you very much for your help!
> Catherine
> --
> View this message in context: http://www.nabble.com/how-to-plot-a-data-by-different-group-tp25862739p25862739.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org




More information about the R-help mailing list