Learn R Programming

export (version 0.3.0)

table2tex: Export statistical output to HTML or Latex table

Description

Export currently showing R stats object or stats object obj to a HTML or Latex table

Usage

table2tex(
  x = NULL,
  file = "Rtable",
  type = "TEX",
  digits = 2,
  digitspvals = 2,
  trim.pval = 1e-16,
  summary = FALSE,
  standAlone = TRUE,
  add.rownames = FALSE,
  ...
)

table2html(...)

Value

No return value

Arguments

x

given R stats object or list of stats objects to export; if set to NULL the output of the previous R command will be exported.

file

name of output file. The appropriate extension is added automatically.

type

desired output type - "TEX" for Latex and "HTML" for HTML.

digits

number of significant digits to show for all columns except for the column with p values.

digitspvals

number of significant digits to show for columns with p values.

trim.pval

a threshold below which the p-values are trimmed as "< trim.pval".

summary

logical indicating whether or not to summarize data files.

standAlone

logical indicating whether exported Latex code should be standalone compilable, or whether it will be pasted into another document.

add.rownames

logical indicating whether the names of the rows should be added to the table (inserting a column before first column).

...

extra options are passed on to stargazer.

Functions

  • table2html(): Export statistical output to HTML table

Author

Tom Wenseleers, Christophe Vanderaa

Details

Objects that can be exported are all those supported by xtable, tidy (see table2office for an extensive list of supported methods), or stargazer. The models supported by stargazer are:

  • aftreg (eha)

  • anova (stats)

  • aov (stats)

  • aovlist (stats)

  • arima (stats)

  • betareg (betareg)

  • binaryChoice (sampleSelection)

  • bj (rms)

  • brglm (brglm)

  • censReg (censReg)

  • coeftest (lmtest)

  • coxph (survival)

  • coxreg (eha)

  • clm (ordinal)

  • clogit (survival)

  • cph (rms)

  • dynlm (dynlm)

  • ergm (ergm)

  • errorsarlm (spdev)

  • felm (lfe)

  • gam (mgcv)

  • garchFit (fGarch)

  • gee (gee)

  • glm (stats)

  • Glm (rms)

  • glmer (lme4)

  • glmrob (robustbase)

  • gls (nlme)

  • Gls (rms)

  • gmm (gmm)

  • heckit (sampleSelection)

  • hetglm (glmx)

  • hurdle (pscl)

  • ivreg (AER)

  • lagarlm (spdep)

  • lm (stats)

  • lme (nlme)

  • lmer (lme4)

  • lmrob (robustbase)

  • lrm (rms)

  • maBina (erer)

  • mclogit (mclogit)

  • mlogit (mlogit)

  • mnlogit (mnlogit)

  • mlreg (eha)

  • multinom (nnet)

  • nlme (nlme)

  • nlmer (lme4)

  • ols (rms)

  • pgmm (plm)

  • phreg (eha)

  • plm (plm)

  • pmg (plm)

  • polr (MASS)

  • psm (rms)

  • rem.dyad (relevent)

  • rlm (MASS)

  • rq (quantreg)

  • Rq (rms)

  • selection (sampleSelection)

  • svyglm (survey)

  • survreg (survival)

  • tobit (AER)

  • weibreg (eha)

  • zeroin (pscl)

  • relogit (zelig)

  • cloglog.net (zelig)

  • gamma.net (zelig)

  • probit.net (zelig)

  • logit.net (zelig)

See Also

table2office ,table2ppt, table2doc, stargazer

Examples

Run this code
# Create a file name
filen <- tempfile(pattern = "table_aov") # or 
# filen <- paste("YOUR_DIR/table_aov")

# Generate ANOVA output
fit=aov(yield ~ block + N * P + K, data = npk) # 'npk' dataset from base 'datasets'
x=summary(fit)

# Export to Latex in standAlone format
if (interactive()) table2tex(x=x,file=filen) 
# Export to Latex to paste in tex document
summary(fit) # get output from the console
if (interactive()) table2tex(file=filen, standAlone = FALSE) 

# Export to HTML
if (interactive()) table2html(x=x,file=filen) # or 
summary(fit) # get output from the console
if (interactive()) table2html(file=filen) 

Run the code above in your browser using DataLab