Re: [R] Data aggregation question

2011-07-29 Thread David Warren
Hi all, table() did the trick, and very efficiently, too! Thanks for the advice, Dave On Thu, Jul 28, 2011 at 5:39 PM, David Winsemius wrote: > > On Jul 28, 2011, at 4:24 PM, David Warren wrote: > > Hi all, >> >>I'm working with a sizable dataset that I'd like to summarize, but I >>

Re: [R] Data aggregation question

2011-07-28 Thread David Winsemius
On Jul 28, 2011, at 4:24 PM, David Warren wrote: Hi all, I'm working with a sizable dataset that I'd like to summarize, but I can't find a tool or function that will do quite what I'd like. Basically, I'd like to summarize the data by fully crossing three variables and getting a co

Re: [R] Data aggregation question

2011-07-28 Thread William Dunlap
Have you tried using table()? E.g., > df <- data.frame(x=c("A","A","B","C"), y=c("ii","ii","i","ii"), Age=2^(1:4)) > tab <- do.call("table", df[c("x","y")]) > tab y x i ii A 0 2 B 1 0 C 0 1 > as.data.frame(tab) x y Freq 1 A i0 2 B i1 3 C i0 4 A ii2 5 B ii0 6

Re: [R] Data aggregation question

2011-07-28 Thread Sarah Goslee
You don't offer a reproducible example, but what do you need that table() doesn't provide? testdata <- data.frame(A=factor(sample(1:3, 20)), B=factor(sample(1:3, 20)), C=factor(sample(1:3, 20))) table(testdata) Sarah On Thu, Jul 28, 2011 at 4:24 PM, David Warren wrote: > Hi all, > >     I'm wor