Fundamentals of Statistics contains material of various lectures and courses of H. Lohninger on statistics, data analysis and here for more.

Contingency Table

If we look at two nominal or ordinal variables having a limited number of categories, we may not only calculate the frequency tables for the individual variables but also a joint frequency table which contains the frequencies of all combinations of categories of both variables. Such a joint frequency table is called contingency table or cross tabulation.(1) This table may either contain absolute or relative fequencies:

absolute frequencies
relative frequencies
    x1 x2 ... xn sum
Y y1 n11 n21 ... nn1 n.1
y2 n12 n22 ... nn2 n.2
... ... ... ... ... ...
ym n13 n23 ... nn3 n.3
sum n1. n2. ... n3. N
    x1 x2 ... xn sum
Y y1 h11 h21 ... hn1 h.1
y2 h12 h22 ... hn2 h.2
... ... ... ... ... ...
ym h13 h23 ... hn3 h.3
sum h1. h2. ... h3. 1.0

In addition to the frequencies of the combination of categories, so called marginal sums, or marginal frequencies,(2) are displayed along with the contingency table. These marginal frequencies are equal to the frequencies of the corresponding categories. The total sum of all entries in the contingency table is either equal to the number of observations N for absolute frequencies, and is equal to 1.0 for relative frequencies.

(1) Sometimes the contingency table is called by different terms, depending on the level of measurement of the data: when applied to ordinal data we speak of a "table of association", with metric data normally the term "correlation table" is used. The expression contingency table is then exclusively reserved for nominal data.
(2) The notation "n.j" and "h.j" (mind the dot in the subscript) describes all values having an arbitrary first index, and a jth second index. Alternatively, we could use new symbols for the marginal sums, which would, however, introduce an unnecessary complication.