Description Usage Arguments Details Value Author(s) Examples
A contingency table returns the counts of all the combinations of
the modalities of two series in a table for which every modality of
the first series is a row and every modality of the second series
is a column. The joint
, marginal
and conditional
functions
compute these three distributions from the contingency table (by
indicating one series for the last two).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
data |
a tibble, |
x1, x2 |
the two series used the construct the contingency table, the distinct values of the first and the second will respectively be the rows and the columns of the contingency table, |
weights |
a series containing the weights that should be used to mimic the population, |
freq |
the frequencies (in the case where data is already contingency table), |
total |
if |
xfirst1, xfirst2, xlast1, xlast2, wlast1, wlast2 |
see |
x |
the series on which the operation should be computed, |
f |
see |
vals |
see |
cont_table
actually returns a tibble in "long format", as the
dplyr::count
table does. As the returned object is of class
cont_table
, this is the format
and print
methods that turns
the tibble in a wide format before printing.
The conditional
and joint
functions return a cont_table
object, as the marginal
function returns a freq_table
object.
a tibble
Yves Croissant
1 2 3 4 5 6 7 8 9 10 | library("dplyr")
# get a contingency table containing education and sex
cont_table(employment, education, sex)
# instead of counts, sum the weights
cont_table(employment, education, sex, weights = weights)
# get the joint distribution and the conditional and marginal
# distribution of sex
cont_table(employment, education, sex) %>% joint
cont_table(employment, education, sex) %>% marginal(sex)
cont_table(employment, education, sex) %>% conditional(sex)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.