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)? E.g., I have same X,Y,CAT and I want to split this up into several sets according to CAT, 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? I have generally solved these problems by massaging the data e.g., for X,Y,CAT case .... data[data$CAT=1,c(1,2)] gives me X,Y for CAT=1, etc. but this seems like a kludge, especially since I have to loop through each unique value of CAT ... Thanks, A.
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