tangram: Table creation methods

View source: R/compile.R

tangram.clmm2R Documentation

Table creation methods

Description

The tangram method is the principal method to create tables. It uses R3 method dispatch. If one specifies rows and columns, one gets an empty table of the given size. A formula or character will invoke the parser and process the specified data into a table like Hmisc::summaryM. Given an rms object it will summarize that model in a table. A data.frame is converted directly into a table as well for later rendering. Can create tables from summary.rms(), anova.rms(), and other rms object info to create a single pretty table of model results. The rms and Hmisc packages are required.

Usage

## S3 method for class 'clmm2'
tangram(
  x,
  id = NULL,
  style = "hmisc",
  caption = NULL,
  footnote = NULL,
  digits = NULL,
  ...
)

## S3 method for class 'summary.clmm2'
tangram(
  x,
  id = NULL,
  style = "hmisc",
  caption = NULL,
  footnote = NULL,
  digits = NULL,
  pformat = "%1.3f",
  include_p = FALSE,
  ...
)

tangram(x, ...)

## S3 method for class 'numeric'
tangram(
  x,
  cols,
  id = NULL,
  caption = NULL,
  style = "hmisc",
  footnote = NULL,
  fixed_thead = NULL,
  ...
)

## S3 method for class 'anova.lme'
tangram(
  x,
  id = NULL,
  style = "hmisc",
  caption = NULL,
  footnote = NULL,
  digits = NULL,
  fixed_thead = NULL,
  ...
)

## S3 method for class 'data.frame'
tangram(
  x,
  id = NULL,
  colheader = NA,
  caption = NULL,
  style = "hmisc",
  footnote = NULL,
  after = NA,
  quant = seq(0, 1, 0.25),
  msd = TRUE,
  as.character = NULL,
  fixed_thead = NULL,
  exclude = NULL,
  ...
)

## S3 method for class 'formula'
tangram(
  x,
  data = NULL,
  id = NULL,
  transforms = NULL,
  caption = NULL,
  style = "hmisc",
  footnote = NULL,
  after = NA,
  digits = NA,
  fixed_thead = NULL,
  exclude = NULL,
  ...
)

## S3 method for class 'character'
tangram(x, ...)

## S3 method for class 'table'
tangram(
  x,
  id = NULL,
  percents = FALSE,
  digits = 1,
  test = FALSE,
  footnote = NULL,
  ...
)

## S3 method for class 'ftable'
tangram(x, id = NULL, ...)

## S3 method for class 'matrix'
tangram(x, digits = NULL, ...)

## S3 method for class 'tbl_df'
tangram(x, ...)

## S3 method for class 'lm'
tangram(x, ...)

## S3 method for class 'summary.lm'
tangram(x, id = NULL, format = NULL, pformat = NULL, tformat = NULL, ...)

## S3 method for class 'rms'
tangram(
  x,
  data = NULL,
  short.labels = NULL,
  footnote = NULL,
  rnd.digits = 2,
  rnd.stats = rnd.digits,
  ...
)

Arguments

x

object; depends on S3 type, could be rows, formula, string of a formula, data.frame or numerical rows, an rms.model

id

character; A unique charcter id used to identify this table over multiple runs. No spaces.

style

character; Desired rendering style, currently supports "hmisc", "nejm", and "lancet". Defaults to "hmisc"

caption

character; A string with the desired caption

footnote

character; A vector of character strings as footnotes

digits

numeric; default number of digits to use for display of numerics

...

addition models or data supplied to table construction routines

pformat

function or character; A function to format p values

include_p

logical; Include p-value when printing statistic

cols

numeric; An integer of the number of cols to create

fixed_thead

logical; On conversion to HTML5 should headers be treated as fixed?

colheader

character; Use as column headers in final table

after

function or list of functions; one or more functions to further process an abstract table

quant

numeric; A vector of quantiles to use for summaries

msd

logical; Include mean and standard deviation in numeric summary

as.character

logical; if true data.frames all variables are passed through as.character and no numerical summary is provided.

exclude

vector or list; When x is a data.frame this exclusion criteria is applied to the data. If this is a list then each list pair is the (column name, criteria). It is preferred to use a list to be specific.

data

data.frame; data to use for rendering tangram object

transforms

list of lists of functions; that contain the transformation to apply for summarization

percents

logical; Display percents when rendering a table object. Defaults to FALSE

test

logical or function; Perform default test or a statistical function that will return a test result when passed a row and column

format

numeric or character; Format to apply to statistic

tformat

numeric or character; format to apply to t-value

short.labels

numeric; Named vector of variable labels to replace in interaction rows. Must be in format c("variable name" = "shortened label").

rnd.digits

numeric; Digits to round reference, comparison, result and CI values to. Defaults to 2.

rnd.stats

numeric; Digits to round model LR, R2, etc to. Defaults to rnd.digits.

Details

Note that additional arguments are passed to any subsequent transform. This means that a lot of possible arguments are not documented here but in the transform applied. Examine their documentations for additional possible arguments if needed.

Value

A tangram object (a table).

See Also

Possible transforms are (see hmisc) (*default*), nejm and lancet.

Examples

tangram(1, 1)
tangram(data.frame(x=1:3, y=c('a','b','c')), id="mytbl1")
tangram(drug ~ bili + albumin + protime + sex + age + spiders, pbc, id="mytbl2")
tangram("drug~bili+albumin+stage::Categorical+protime+sex+age+spiders", pbc,"mytbl3")

spgarbet/tg documentation built on Feb. 21, 2023, 3:35 a.m.