R/t.test.r

#' Aggregate function to perfom one and two sample t-tests
#'
#' @title Performs one and two sample t-tests
#'
#' @param a a numeric vector of data values
#' @param b a numeric vector of data values
#' @param alternative an integer specifying the alternative hypothesis,
#' 1 for "two.sided"’ (default), 2 for "greater" or 3 for "less".  
#' @param mu a number indicating the true value of the mean (or difference
#' in means if you are performing a two sample test).
#' @param paired a logical indicating paired non-paired t-test.
#' @param var.equal a logical variable indicating whether to treat the two
#' variances as being equal.  If ‘TRUE’ then the pooled variance
#' is used to estimate the variance otherwise the Welch (or satterthwaite) 
#' approximation to the degrees of freedom is used.
#' @param conf.level confidence level of the interval.
#' @return a 2D table
#' @examples
#' \dontrun{
#' # put example here
#'}
#' @export
t.test <- function (x, y = NULL, alternative = 1, mu = 0, paired = FALSE, var.equal = FALSE,
          conf.level = 0.95) {
  if(alternative == 1){alternative <- "two.sided"}
  if(alternative == 2){alternative <- "less"}
  if(alternative == 3){alternative <- "greater"}
  t.test(x, y, alternative, mu, paired, var.equal, conf.level)
}
datashield/dsteststats documentation built on May 14, 2019, 7:52 p.m.