build: Formats Regression Tables to Text, LaTeX, and HTML

Description Usage Arguments Value Examples

View source: R/build.R

Description

Constructs a regression table for one or more models with a wide variety of available customizations.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
build(
  ...,
  dep_names = NULL,
  indep_names = NULL,
  note = "",
  title = "Model results",
  max_precision = 3,
  path = NULL,
  silent = FALSE,
  landscape = FALSE,
  report = "p",
  annotations = "oraf",
  custom_annotations = NULL,
  md = NULL,
  header = TRUE,
  label = "table",
  sig = NULL,
  as_table = TRUE,
  grouped_label = NULL
)

Arguments

...

Regression models to be included in Table. Table will display models in the same order as provided.

dep_names

Character vector of dependent variable names. Vector should be listed in the same order that the models will be displayed (from left to right). If NULL, the columns will be numbers (e.g. (1), (2)....)

indep_names

List of names associating independent variable names with desired names in table.

note

Optional note displayed in bottom row of the table. Notes only display in LaTeX and HTML output types.

title

Title of the table.

max_precision

Maximum number of digits in a table cell.

path

Output path for the tex file. NA for no tex output.

silent

No text output if true.

landscape

If true, the Latex table will be landscaped.

report

Test statistic to be provided along with the coefficient. Must be either "p", "t", or "ste". Default value is "p".

annotations

Fit characteristics to be provided at bottom of table. Must be a string of reporters. Options include "o" for number of observations, "r" for R2, "a" for adjusted R2 and "f" for f-statistic. The inputted string determines the order of outputted reporters. See vignette for full list of possible values. Ex annotations='oraf'.

custom_annotations

List of optional reporters to be provided above normal fit characteristics. The list must be formatted as the name of the reporter followed by a a vector of values. Ex custom_annotations=list('R.St.E' = c('True', 'True')).

md

Allows for outputting in either latex ("latex") or html ("html") for Rmarkdown formatting. The Markdown chunk must be set to results = "asis".

header

Includes RCHITEX header as a Latex comment if true.

label

Latex label.

sig

List containing the associations between significance symbols and cut-off p values. (ex list('***' = 0.01, '**' = 0.05, '*' = 0.1)).

as_table

True values wrap the underlying Latex Tabular object in a table.

grouped_label

Optional label printed above model names that group models together. Expected format is a list of the name and a vector of the start and end columns.

Value

Invisible return containing rchitex object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library(rchitex)
data(swiss)

mod1 <- lm(data=swiss, Fertility ~ Agriculture + Education)
mod2 <- lm(data=swiss, Fertility ~ Agriculture + Education +
 Infant.Mortality + Catholic + Examination)
lmod <- glm(data=swiss, I(Fertility > mean(Fertility)) ~ Agriculture +
              Education + Infant.Mortality + Catholic + Examination,
            family=binomial(link='logit'))

indep_names <- list('Agriculture' = "Agriculture share", 'Education' =
 'Total education',
                    'Infant.Mortality' = 'Infant Mortality',
                    'Catholic' = 'Catholic share', 'Examination' = 'Exam')
dep_names <- c('Fert.', 'Fert.', 'Fert.')
grouped_label <- list('OLS' = c(1,2), 'logit' = 3)
custom_annotations <- list('Full dataset' = c('No', 'Yes', 'Yes'))
sig <- list('***' = 0.001, '**' = 0.025, "'"=0.15)

build(mod1, mod2, lmod, indep_names=indep_names, dep_names=dep_names,
grouped_label=grouped_label, custom_annotations=custom_annotations, sig=sig,
title='Example regression from Swiss dataset', report='t',
annotations='orc')

bdempe18/rchitex documentation built on Nov. 9, 2020, 11:33 p.m.