Run a Welch t-test and return a tidy data frame with means, SDs, t-statistic, p-value and significance stars.
extract_t_test <- function(x, y, ...) {
z <- t.test(x, y)
stat <- z$statistic
pval <- z$p.value
pvalStars <- ifelse(pval > 0.05, ".",
ifelse(pval > 0.01, "*",
ifelse(pval > 0.001, "**", "***")))
est <- z$estimate
sdv <- c(sd(x), sd(y))
res <- data.frame(est[1], sdv[1], est[2], sdv[2], stat, pval, pvalStars)
res[1:4] <- round(as.numeric(res[1:4]), 2)
names(res) <- c("Mean x", "sd x", "Mean y", "sd y", "t", "Pvalues", "P")
return(res)
}