Learn R Programming

texreg (version 1.15)

texreg: Convert regression output to LaTeX tables

Description

Conversion of R regression output to LaTeX tables.

Usage

texreg(l, single.row=FALSE, no.margin=TRUE, leading.zero=TRUE, 
    table=TRUE, sideways=FALSE, float.pos="", stars=TRUE, 
    strong.signif=FALSE, symbol="\\cdot", use.packages=TRUE, 
    caption="Statistical models", label="table:coefficients", 
    dcolumn=TRUE, booktabs=TRUE, scriptsize=FALSE, 
    custom.names=NA, model.names=NA, digits=2, ...)

Arguments

l
A statistical model or a list of statistical models. Lists of models can be specified as l = list(model.1, model.2, ...). Different object types can also be mixed.
single.row
By default, a model parameter takes up two lines of the table: the standard error is listed in parentheses under the coefficient. This saves a lot of horizontal space on the page and is the default table format in most academic journals. If single.r
no.margin
In order to save space, inner margins of tables are switched off by default. To reactivate the default table spacing, set no.margin=FALSE.
leading.zero
Most journals require leading zeros of coefficients and standard errors (for example, 0.35). This is also the default texreg behavior. Some journals, however, require omission of leading zeros (for example, .35). This can be achi
table
By default, texreg puts the actual tabular object in a table floating environment. To get only the tabular object without the whole table header, set table=FALSE.
sideways
If sideways=TRUE is set, the table floating environment is replaced by a sidewaystable float, and the rotating package is loaded in the preamble. The argument only has an effect if table=TRUE
float.pos
This argument specifies where the table should be located on the page or in the document. By default, no floating position is specified, and LaTeX takes care of the position automatically. Possible values include h (here), p (pag
stars
Should significance stars be printed after coefficients/standard errors, and should a note about significance levels be printed below the table?
strong.signif
Conventional regression tables report 99 percent significance as three stars, 95 percent as two stars, and 90 percent as one star. For ERGMs, however, the de facto standard is to report 99.9 percent as three stars, 99 percent as two stars, 95 percent as o
symbol
By default, p values smaller than 0.1 and larger than 0.05 are reported as dots (symbol="\\cdot") when strong.signif=TRUE is set. Any other mathematical LaTeX symbol can be used, for example symbol="\\circ".
use.packages
If this argument is set to TRUE (= the default behavior), the required LaTeX packages are loaded in the beginning. If set to FALSE, the use package statements are omitted from the output.
caption
Set the caption of the table environment.
label
Set the label of the table environment.
dcolumn
Use the dcolumn LaTeX package to get a nice alignment of the coefficients.
booktabs
Use the booktabs LaTeX package to get thick horizontal rules in the output table.
scriptsize
To save horizontal space on the page, the table can be set in script size instead of normal text size by setting scriptsize=TRUE.
custom.names
By default, texreg uses the coefficient names which are stored in the models. The custom.names argument can be used to replace them by other character strings in the order of appearance. For example, if a table shows a total of three differen
model.names
A string vector of labels for the models. By default, the models are named Model 1, Model 2, etc. Specifying model.names=c("My name 1", "My name 2") etc. overrides the default behavior.
digits
Set the number of decimal places for coefficients, standard errors and goodness-of-fit statistics. Do not use negative values!
...
Custom options to be passed on to the extract function.

Details

texreg converts coefficients, standard errors, significance stars, and goodness-of-fit statistics of statistical models into LaTeX tables. Either a single model or a list of models can be combined in a single table. The output is customizable. Models can be handed over as lists of objects. New model types can be easily implemented.

See Also

texreg-package extract extract-methods

Examples

Run this code
#Linear mixed-effects models
library(nlme)
model.1 <- lme(distance ~ age, data = Orthodont, random = ~ 1)
model.2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
table.string <- texreg(list(model.1, model.2))
cat(table.string)

#Ordinary least squares model (example from the 'lm' help file)
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2,10,20, labels=c("Ctl","Trt"))
weight <- c(ctl, trt)
lm.D9 <- lm(weight ~ group)
table.string <- texreg(lm.D9)
cat(table.string)

Run the code above in your browser using DataLab