R/t_of_r.R

Defines functions t_of_r

Documented in t_of_r

#' T-score of a Pearson correlation coefficient
#' @param r Pearson correlation coefficient
#' @param n number of observations
#' @export
t_of_r <- function(r, n){
        t <- r*sqrt(n-2)/sqrt(1-r^2)
        p.2t <- 2 * min(
                c(
                pt(t, n-2),
                pt(t, n-2, lower.tail = FALSE)
                )
        )
        res <- c(t, p.2t)
        names(res) <- c("t", "p.2t")
        res
}
alitvak3/a3personal documentation built on April 6, 2021, 4:53 a.m.