table_f {ltable}R Documentation

Function table_f

Description

Constructs tables of counts and proportions out of data sets.

Usage

table_f(data, datavars, type=1, digits=2, extended=FALSE, MV=FALSE, cb=FALSE)

Arguments

data

name of the data set; object of data.frame class

datavars

the character string that lists field names separated by comma in the order of presentation in the table: first has its sorted levels rolled out vertically leftmost, the last has its sorted levels spread by columns

type

the type of table: 1 (default) - count table; 2 - proportions by rows; 3 - proportions by columns; 4 - frequencies

digits

formats output digits number, applied only to proportions, default is 2

extended

TRUE adds margins of counts, applied only for proportions and frequencies, FALSE by default

MV

includes missing values into tabulation, operates with type=1 only, FALSE by default

cb

TRUE permits to copy the table to clipboard, FALSE by default

Details

Value

returns object of class data.frame

Note

Abstain from putting continuous variables or too many factor variables into datavars list to keep table legible. Put factor variable with numerous levels at the end of the list.

Author(s)

Ocheredko Oleksandr Ocheredko@yahoo.com

Examples

data(sdata, package="ltable")
table_f(sdata, "a")
table_f(sdata, "a", MV=TRUE, extended=TRUE)
knitr::kable(table_f(sdata, "a,b,c"))
table_f(sdata, "a,b,c,d", type=2, digits=3)
table_f(sdata, "b,c,a,d", MV=TRUE, extended=TRUE, cb=TRUE)

[Package ltable version 2.0.3 Index]