kTable: Make Nicely Formatted Tables

Description Usage Arguments Examples

Description

Function for creating nice 1D and 2D tables. Tables are generated and formatted with both counts and percentages. Primarily intended to be used with R Markdown documents, calling some of the table printing functions. The function returns a data.frame in a format that can be used with utility HTML generation functions.

Usage

1
2
3
kTable(x, y = NULL, deparse.level = 2, top.left.cell = "",
  col.names = NULL, row.names = NULL, left.label = NULL,
  top.label = NULL, google = FALSE)

Arguments

x

the x variable to build a table on.

y

optional: the y variable to build a table on. Used for 2x2 contingency tables.

deparse.level

passed to table; deparse.level=2 allows us to pass through variable names.

top.left.cell

the string to set in the top left cell of the table.

col.names

a vector of column names to use on the outputted table; typically this is parsed from the variables passed through.

row.names

a vector of row names to use on the outputted table; typically this is parsed from the variables passed through.

left.label

the label to use for the rows; typically parsed from x. Only used for 2D tables (ie, when y is not null).

top.label

the label to use for the columns; typically parsed from y. Only used for 2D tables (ie, when y is not null).

google

used if you plan on passing the table to gvistable from the googleVis package.

Examples

1
2
3
4
5
6
7
x <- rbinom(100, size=2, p=0.1)
y <- rbinom(100, size=2, p=0.1)

## try these in an R markdown document for best results
kTable(x)
my_table <- kTable(x, y, top.left.cell="foo", left.label="bar", top.label="baz")
pxt( my_table )


Search within the Kmisc package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.