Hello, I try to compute means,sd,n from a variable y according to some categoricals g1,g2... I wrote the following function:
msd<-function(y,...) {
print(match.call())
funy<-function(x) list(mean(x,na.rm=T),sd(x,na.rm=T),table(is.na(x))[1])
gg <- list(...)
aa<-by(y,gg,funy)
bb<-matrix(unlist(aa),nrow=3)
bb
}
this works OK so far there is no empty cell in the crosstab, if there is, the unlist statement just run over it and I do not know which cell is missing, any attempt to label the columns in matrix bb then fail.
Can somebody suggest a method to retrive the list names from aa to label the columns of the matrix bb?
Thanks for any help
Heberto Ghezzo
McGill University
Montreal Canada


______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to