search for: xtab2

Displaying 1 result from an estimated 1 matches for "xtab2".

Did you mean: xtabs
2002 May 23
2
crosstabulation of means
Hello, I am trying to print a crosttabulation of mean,sd,n for a continuous variable crossclassified by anoother/s grouping variables. I came up with: xtab2 <- function(x,g1,g2) { funy <- function(z) list(mean(z,na.rm=T),sd(z,na.rm=T),length(z)) aa <- by(x,list(g1,g2),funy) bb <- matrix(unlist(aa),nrow=3 ,dimnames=list(c("mean","sd","n"), rep(levels(as.factor(g2)), rep(l...