R/pctab.R

Defines functions pctab

Documented in pctab

pctab <- function( TT, margin=length( dim( TT ) ), dec=1 )
  {
  nd <- length( dim( TT ) )
  sw <- (1:nd)[-margin[1]]
  rt <-
  sweep( addmargins( TT,
                     margin,
                     list( list( All=sum,
                                   N=function( x ) sum( x )^2/100 ) ) ),
         sw,
         apply( TT,
                sw,
                sum )/100,
         "/" )
  if( dec ) print( round( rt, dec ) )
  invisible( rt )
  }

Try the Epi package in your browser

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

Epi documentation built on April 25, 2023, 9:09 a.m.