Displaying 1 result from an estimated 1 matches for "add_margin".
Did you mean:
add_margins
2011 Oct 23
2
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=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)
Amargin <- tapply(x, list(A), mean)
Bmargin <- tapply(x, list(B), mean)