Skip to content

Instantly share code, notes, and snippets.

@artemklevtsov
Created December 4, 2015 01:52
Show Gist options
  • Save artemklevtsov/5a9c321120704a34292e to your computer and use it in GitHub Desktop.
Save artemklevtsov/5a9c321120704a34292e to your computer and use it in GitHub Desktop.
as.data.frame.htest <- function(x) {
res <- list()
if (grepl("correlation", x$method) && !is.null(x$estimate))
res[names(x$estimate)] <- x$estimate
else if (!is.null(x$statistic))
res[names(x$statistic)] <- x$statistic
if (!is.null(x$parameter))
res[names(x$parameter)] = x$parameter
if (!is.null(x$p.value)) {
res$p.value <- x$p.value
res$sign <- ifelse(x$p.value > 0.05, "", ifelse(x$p.value > 0.01, "*", ifelse(x$p.value > 0.001, "**", "***")))
}
if (!is.null(x$alternative))
res["alternative"] = x$alternative
as.data.frame(res, stringsAsFactors = FALSE)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment