Skip to content
Prev 314766 / 398502 Next

Function to tabulate t-test (1) How can I get dependent variable name (2) How can I make data frame know to function

I've just realized that you're swapping female and male in the creation 
of the results data frame.
It should be

Table2 <- function(formula, data) {
     dname <- rownames(attr(terms(formula), "factors"))[1]
     temp <- t.test(formula, data)
     mydf <- data.frame(dep=temp$data.name,
              female=temp$estimate[2], male=temp$estimate[1],
              p=temp$p.value,
              CILow=temp$conf.int[1],CIHigh=temp$conf.int[2])
     row.names(mydf) <- NULL
     mydf
}


Rui Barradas

Em 07-01-2013 15:39, Rui Barradas escreveu: