R/apa.tstat.r

#' @title apa.tstat
#'
#' @description APA formating for t statistic
#'
#' @export
#'
#' @param t t statistic to be formatted
#' @param df degrees of freedom
#' @return the formatted value as a \code{\link[base]{character}}
#'
#' @author Mark Newman, \email{mark@trinetteandmark.com}
#' @keywords statistic
#' @family statistic
#' 
#' @examples
#'   ts = apa.tstat(0.0342, 5)
#'   tss = apa.tstat(c(1.1234, 2.0007, 0.0342), c(5, 2.3, 6.006))
#'   # In the markdown put `r ts` or `r tss`
#'
apa.tstat = function(t, df) {
  
  res = sprintf("$t$(%s) = %s", round(df, 2), round(t, 3))
  
  return(res)
}
markanewman/apaformat documentation built on May 10, 2019, 1:19 a.m.