ds_cross_table: Two way table

Description Usage Arguments Examples

View source: R/ds-cross-table.R

Description

Creates two way tables of categorical variables. The tables created can be visualized as bar plots and mosaic plots.

Usage

1
2
3
4
5
6
ds_cross_table(data, var_1, var_2)

## S3 method for class 'ds_cross_table'
plot(x, stacked = FALSE, proportional = FALSE, print_plot = TRUE, ...)

ds_twoway_table(data, var_1, var_2)

Arguments

data

A data.frame or a tibble.

var_1

First categorical variable.

var_2

Second categorical variable.

x

An object of class cross_table.

stacked

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

proportional

If TRUE, the height of the bars is proportional.

print_plot

logical; if TRUE, prints the plot else returns a plot object.

...

Further arguments to be passed to or from methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# cross table
k <- ds_cross_table(mtcarz, cyl, gear)
k

# bar plot
plot(k)

# stacked bar plot
plot(k, stacked = TRUE)

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

# returns tibble
ds_twoway_table(mtcarz, cyl, gear)

rsquaredacademy/descriptr documentation built on July 9, 2021, 8:13 p.m.