R/stdres.table.R

Defines functions stdres.table

Documented in stdres.table

stdres.table <- function(x, y, weights = NULL, na.rm = FALSE, na.value = "NAs", digits = 3, residuals = "std") {
  
  t <- weighted.table(x, y, weights, na.rm = na.rm, na.value = "NAs", digits = NULL)
  temp <- suppressWarnings(stats::chisq.test(t))
  std <- as.table(temp$residuals)
  adj <- as.table(temp$stdres)

  if(residuals == "std") {
    return(round(std, digits))
  } else if(residuals == "adj") {
    return(round(adj, digits))
  }
  
}

Try the descriptio package in your browser

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

descriptio documentation built on June 8, 2025, 10:50 a.m.