Re: [R] Summary stats in table

2011-10-30 Thread Duncan Murdoch
On 11-10-24 7:16 PM, Hadley Wickham wrote: On Mon, Oct 24, 2011 at 5:39 AM, Duncan Murdoch wrote: Suppose I have data like this: A<- sample(letters[1:3], 1000, replace=TRUE) B<- sample(LETTERS[1:2], 1000, replace=TRUE) x<- rnorm(1000) I can get a table of means via tapply(x, list(A, B), mea

Re: [R] Summary stats in table

2011-10-24 Thread Hadley Wickham
On Mon, Oct 24, 2011 at 5:39 AM, Duncan Murdoch wrote: > Suppose I have data like this: > > A <- sample(letters[1:3], 1000, replace=TRUE) > B <- sample(LETTERS[1:2], 1000, replace=TRUE) > x <- rnorm(1000) > > I can get a table of means via > > tapply(x, list(A, B), mean) > > and I can add the marg

Re: [R] Summary stats in table

2011-10-23 Thread Tyler Rinker
gt; Date: Sun, 23 Oct 2011 14:39:08 -0400 > From: murdoch.dun...@gmail.com > To: R-help@r-project.org > Subject: [R] Summary stats in table > > Suppose I have data like this: > > A <- sample(letters[1:3], 1000, replace=TRUE) > B <- sample(LETTERS[1:2], 1000, replace=TRU

[R] Summary stats in table

2011-10-23 Thread Duncan Murdoch
Suppose I have data like this: A <- sample(letters[1:3], 1000, replace=TRUE) B <- sample(LETTERS[1:2], 1000, replace=TRUE) x <- rnorm(1000) I can get a table of means via tapply(x, list(A, B), mean) and I can add the marginal means to this using cbind/rbind: main <- tapply(x, list(A,B), mean)