Next: tan() Up: MacAnova Help File Previous: t2val()   Contents


tabs(y [,a,b,...] [, mean:T, var:T, covar:T, count:T or n:T, stddev:T,\
  min:T, max:T, sum:T, prod:T]), y REAL vector or matrix, a, b,
  ... factors, LOGICAL or positive integer vectors
tabs(y [,a,b,...], all:T [,mean:F, var:F, ...] [,covar:T])
tabs(,a,b,...[,count:T or n:T])

Keywords: categorical data, descriptive statistics
tabs(y,a,b,c,...) computes summary statistics from data in REAL vector
or matrix y for each "cell" defined by grouping variables a, b, c, ... .
The values in a, b, c, ... must be positive integers < 32768, considered
as category levels, or MISSING.  In particular, a, b, c, ... can be
factors.  See factor().

By default, the output is a structure with components 'mean' containing
cell means, 'var' containing cell variances, and 'count' containing cell
sample sizes, but this can be modified by keywords.

The values in each component, including 'count', are based on the
non-MISSING elements of y.  When a cell has no non-MISSING values, the
count is 0 and any statistics computed are MISSING.

When y has MISSING elements, a warning message is printed.  When a
factor has elements that are MISSING, the corresponding value of y is
ignored and a warning message is printed.

When there are nFact grouping variables and y is a vector or a matrix
with 1 column, each component of the output is an array with nFact
dimensions.  When y is a matrix with nv = ncols(y) > 1, each component
is an array with nFact + 1 dimensions, the last of which is nv.

tabs(y,a,b,c,..., silent:T) does the same except warning messages are

Any grouping variable can be a LOGICAL vector, with False and True
corresponding to levels 1 and 2, respectively.  For example, tabs(y,
x1<=0, x2<=0) cross tabulates y according to the signs of x1 and x2.
See topic 'logic'.

When you want to cross tabulate data according to the values of either
non-integer REAL or CHARACTER vectors, use pre-defined macro
makefactor() to create corresponding factors.  See topic makefactor().

When grouping variables a, b, c, ... are simple vectors and not factors
created by factor(), the length of each dimension is the maximum value
of the grouping variable.

When a grouping variable is a factor, the size of its dimension is the
"official" number of levels, even if the last level is empty, as can be
the case when it has the form f[J], where f is a factor and J is a
vector of subscripts.  See subtopic 'subscripts:"subscripted_factor"'.

tabs(y), with no factor arguments, computes statistics for y as a whole.
Each component of the result is a scalar or a vector of length ncols(y).
This usage is similar to describe(y) except fewer statistics are
computed and the sample size component is called 'count' rather than
'n'.  See describe().

tabs(NULL,a,b,...) or tabs( ,a,b,...), with no first argument, just
computes the counts in each cell, returning a vector, matrix or array.
See topic 'NULL'.

                Controlling which quantities to compute
When one of the keyword phrases 'mean:T', 'var:T', 'count:T',
'stddev:T', 'min:T', 'max:T', 'sum:T', 'prod:T' or 'covar:T' is an
argument, tabs() returns a REAL vector, matrix or array containing the
means, variances, counts, standard deviations, minima, maxima, sums,
products or covariance matrices of the values in each cell.  When more
than one of these keyword phrases are arguments, the result is a
structure with component names matching the keywords.

With 'covar:T', there can be no MISSING values in y and the result or
component 'covar' of the result is an array with nfact + 2 dimensions,
the last two of which are both ncols(y).

  tabs(y,a,b,mean:T,var:T,count:T) is equivalent to tabs(y,a,b).
  tabs(y,mean:T,var:T,count:T) is equivalent to tabs(y).
  tabs(y,a,b,mean:T) computes only a matrix of cell means
  tabs(y,a,b,mean:T,stddev:T,min:T,max:T) computes a 4 component
    structure of means, standard deviations and extremes for each cell
  tabs(y,a,b,sum:T,prod:T) computes a 2 component structure whose
    components are matrices of sums and products of all elements in
    each cell
  tabs(y,mean:T,stddev:T,silent:T) computes statistics for y as a whole;
    no warning message is printed when y has MISSING elements
  tabs(y,a,b,mean:T,count:T,covar:T) computes 3 dimensional arrays of
    cell counts and means and a 4 dimensional covariance matrix array
  tabs(y,covar:T) computes the ncols(y) by ncols(y) covariance matrix.

Alternatively, you can use keyword phrase 'all:T' to compute all
quantities except the covariance matrix for each cell.  You can suppress
specific computations by, for example, 'sum:F' and 'prod:F', or force
computation of covariance matrices by 'covar:T'.

  tabs(y,a,b,all:T,stddev:F,min:F,max:F,sum:F,prod:F) is equivalent
  to tabs(y,a,b)

You can use 'n:T' and 'n:F' instead of 'count:T' and 'count:F'.
However, with 'n:T', the corresponding component of the result will
still be named 'count'.

When y is NULL or absent, only 'count:T' or 'n:T' are permitted and at
least one factor is required.

Gary Oehlert 2003-01-15