#' One-sample z-test
#'
#' @param x numeric vector
#' @param mu number
#'
#' @return number
#' @export
#'
#' @examples
#' z_test(rnorm(50), mean(rnorm(50)))
z_test <- function(x, mu){
z <- abs(mean(x) - mu)/se(x)
output_message <- paste0("sample mean ", round(mean(x), 2))
sign_flag <- if (z > 1.96) "significantly" else "not significantly"
output_message <- paste0(output_message, " ", sign_flag, " different from ", round(mu, 2))
return(output_message)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.