#' @title apa.pvalue
#'
#' @description APA formating for p-values
#'
#' @export
#'
#' @param pv p-value to be formatted
#' @return the formatted value as a \code{\link[base]{character}}
#'
#' @author Mark Newman, \email{mark@trinetteandmark.com}
#' @keywords statistic
#' @family statistic
#'
#' @examples
#' pv = apa.pvalue(0.0342)
#' pvs = apa.pvalue(c(0.0342, 0.0342, 0.0342))
#' # In the markdown put `r pv` or `r pvs`
#'
apa.pvalue = function(pv) {
res = ifelse(pv < .05, ifelse(pv < .01, ifelse(pv < .001, "< .001", "< .01"), "< .05"), "> .05")
res = sprintf("(p %s)", res)
return(res)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.