table_f: Function _table_f_

table_fR 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

  • You can construct table with data set fields of factor, character, logical, and numeric classes.

  • To insert table into Word document first open Excel, choose left high corner of placement by mouse click and use Ctrl+V combination or click on the Paste icon (the clipboard), then use Ctrl+C, open Word document, use Ctrl+V to place the table.

  • If You want to use clipboard to insert table into Word document use option cb=TRUE. You will be asked to confirm, for previous information of clipboard would be lost.

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)

ltable documentation built on Aug. 17, 2023, 1:06 a.m.