Learn R Programming

ltable (version 2.0.2)

table_f: 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)

Value

returns object of class data.frame

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

Author

Ocheredko Oleksandr Ocheredko@yahoo.com

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab