[R] Regarding categorization or grouping of data

Sean Davis sdavis2 at mail.nih.gov
Tue Mar 7 20:25:54 CET 2006




On 3/7/06 2:20 PM, "Andrew Athan" <aathan_R_1542 at memeplex.com> wrote:

> 
> Could someone please provide a examples regarding "best practice" for
> grouping and/or categorization of data?
> 
> E.g., if I have a data page with columns X,CAT where CAT is an integer
> 1-10, and I want to create a new data page where for each value of CAT I
> have the sum(X)?

See ?aggregate or ?by.

> E.g., I have same X,Y,CAT and I want to split this up into several sets
> according to CAT,

See ?split

> E.g., I want to plot each set of X,Y per CAT using a different color for
> each CAT ... perhaps on the same graph?

You might want to look at the lattice package for some techniques for
dealing with grouped data.  If you want a simpler solution, look at using
lines() and points() to add lines or points to a graph.

Sean




More information about the R-help mailing list