descriptr (version 0.3.0)

ds_cross_table: Two Way Tables

Description

ds_cross_tablecross_table creates two way tables of categorical variables. The tables created can be visualized as barplots and mosaicplots.

Usage

ds_cross_table(var1, var2)

# S3 method for ds_cross_table plot(x, beside = FALSE, proportional = FALSE, ...)

# S3 method for ds_cross_table mosaicplot(x, ...)

Arguments

var1

First categorical variable

var2

Second categorical variable

x

An object of class cross_table

beside

a logical value. If FALSE, the columns of height are portrayed as stacked bars, and if TRUE the columns are portrayed as juxtaposed bars.

proportional

a logical value. If TRUE, the height of the bars is proportional

...

further arguments to be passed to or from methods.

Value

ds_cross_table returns an object of class "ds_cross_table". An object of class "ds_cross_table" is a list containing at least the following components:

obs

obs number of observations

var2_levels

levels of the second categorical variable

var1_levels

levels of the first categorical variable

varnames

names of the variables

twowaytable

table of the variables

percent_table

table of percentages

row_percent

table of row percentages

col_percent

table of column percentages

column_totals

total of columns

percent_column

total of columns as a percentage

Deprecated Function

ds_cross_table() has been deprecated. Instead use ds_cross_table().

Examples

Run this code
# NOT RUN {
k <- ds_cross_table(mtcars$cyl, mtcars$am)
k

# bar plots
plot(k)
plot(k, beside = TRUE)
plot(k, proportional = TRUE)

# mosaic plots
mosaicplot(k)
# }

Run the code above in your browser using DataLab