R/permTestPaired.formula.R

Defines functions permTestPaired.formula

Documented in permTestPaired.formula

#' @describeIn permTestPaired Permutation test for paired data.
#' @export

permTestPaired.formula <-
function(formula,  data, subset ,  ...)
{

    if (missing(formula) || (length(formula) != 3L) || (length(attr(terms(formula[-2L]),
        "term.labels")) != 1L))
        stop("'formula' missing or incorrect")

    m <- match.call(expand.dots = FALSE)
    if (is.matrix(eval(m$data, parent.frame())))
        m$data <- as.data.frame(data)
     m[[1L]] <- as.name("model.frame")
     m$... <- NULL
     mf <- eval(m, parent.frame())
     if (length(mf)!= 2L)
       stop("Invalid formula")

     nmiss <- length(attr(mf, "na.action"))
     if (nmiss > 0)
      cat("\n ", nmiss, "observation(s) removed due to missing values.\n")
    varnames <- names(mf)
    response <- attr(attr(mf, "terms"), "response")
    y <- mf[[response]]
    x <- mf[[-response]]
    y <- do.call("permTestPaired", list(x, y, x.name=varnames[2], y.name=varnames[1],...))
    y
}

Try the CarletonStats package in your browser

Any scripts or data that you put into this service are public.

CarletonStats documentation built on Aug. 22, 2023, 5:06 p.m.