R/check_P.R

Defines functions check_P

check_P <- function(P, method, test, n, ncol_x2, ncol_x) {
  check_format <- function(p){
    out <- F
    switch(class(p),
           "matrix" = {out <- !is.logical(tryCatch(as.Pmat(P),error = function(e){T}))},
           "Pmat" = {out <- T})
    return(out)}

  nrow_n <- method != "huh_jhun"
  check <- F
  switch(paste(nrow_n),
         "TRUE" = {if(check_format(P)& NROW(P) == n){check <- T}},  ###NOT huh jhun control class et dimension
         "FALSE" = { ####huh jhhun
           switch(test,
                  "t" = {if(check_format(P)& NROW(P) == n-ncol_x+1){check <- T}},
                  "fisher" = {
                    switch(class(P),
                           "list" = {
                             if(all(c(sapply(P,function(p){check_format(p)}),
                                      sapply(P,function(p){NROW(p)})== n - ncol_x + ncol_x2))){check <- T}})})})
  return(check)
}

Try the permuco package in your browser

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

permuco documentation built on June 30, 2022, 9:05 a.m.