Export Tables to LaTeX or HTML

Coerce data to LaTeX and HTML tables.



  • Added function print.xtableMatharray to enable easy creation of LaTeX code to enable an array to be included in a document.
  • Added example to the gallery using sanitizing headings and row names to produce large bold headings and italic row names.
  • Added code from Martin Gubri, martin.gubri@framasoft.org, to produce tables from the spatial econometrics packages, spdep, splm, and sphet.
  • Extracted sanitize functions from print.xtable as stand-alone functions, and exported them. Added helper functions as.is and as.math for assistance with sanitization (supplied by Stefan Edwards sme@iysik.com in Feature Request #5303).
  • Added option to produce math style exponents when sanitizing numbers, as suggested by Don Armstrong don@donarmstrong.com, who also provided code
  • Fixed bug #6907. Warning was created when the data frame as no rows for type is 'html'. Added a test to create the matrix requested specially in that case. Original code was BTD2 <- matrix(align.tmp[(2-pos):(ncol(x)+1)], nrow = nrow(x), ncol = ncol(x)+pos, byrow = TRUE) which created a matrix with no rows, but gave a warning when there were no rows in the data frame being processed.
  • Fixed bug #6260. Accepted the change suggested by Claudius Loehnert, which was to replace { and } by \begingroup and \endgroup respectively as the delimiters when size was to changed in a table.
  • Added functions xtableList and print.xtableList to produce composite tables consisting of a number of subtables.
  • Added xtableFtable and print.xtableFtable to format flat tables produced by ftable. Included examples in the xtable gallery.
  • Produced new vignettes: 'The xtableList Gallery' to illustrate xtableList and print.xtableList; and 'The Other Packages Gallery' to illustrate methods for classes of objects from other packages.

1.8-0 (2015-11-02)

  • autoformat, xalign, xdigits, xdisplay from Arni Magnusson, added along with help file. Feature request #5686.
  • New argument 'auto' in xtable(), to call xalign, xdigits, and xdisplay at the time when xtable is created.
  • Updated xtableGallery vignette, now with TOC and revised examples.

1.7-4 (2014-09-11)

  • Changed tags in HTML to be all lower case, to be compatible with HTML5, part of feature request. (#5879)
  • Fixed booktabs bug (#2309), more of an enhancement really. Updated xtableGallery.snw to illustrate the change.

1.7-3 (2014-03-06)

  • Dealt with format.args bug (#4770). No code changes, but the documentation of print.xtable was changed to warn of the problem and to give a workaround as an example.

1.7-1 (2013-02-24)

  • Fixed logicals bug. (Req #1911)
  • Changed implementation of centering of tables. Instead of inserting a centered environment, now a \centering command is inserted. (Req #2104)
  • Allow for margin tables as possible with document class tufte-handout. An example of usage is found in the vignette. produced by margintable.Rnw which is in inst/doc. (Req #2168)
  • Added "timestamp" argument to print.xtable(). Set it to NULL if no timestamp is desired. (Req #2246)
  • Added "comment" argument to print.xtable(). Set it to FALSE to exclude the version and timestamp comment. (Req #2246)
  • Added "caption.width" argument. If not NULL then the caption is placed in a "parbox" of the specified width. (Req #2247)
  • Remove the check on whether the "floating.environment" is in a list of known floating environments. Users want to use floating environments from multiple options LaTeX packages. (Req #2488, #2578)

1.7-0 (2012-02-10)

  • Added some vectorization code to improve performance.
  • Let "caption" be length 2, in which case the second value is the short caption used when creating a list of tables.
  • Added "toLatex" method.
  • Included "print.xtable" in the exported methods in the NAMESPACE file.
  • Added "print.results" argument to "print" that can be used to suppress the printing.
  • Added "format.args" argument to "print" that can be used to pass additional arguments such as "big.marks" to "formatC()".
  • Added "rotate.colnames" and "rotate.rownames" arguments to "print.xtable".
  • Added "booktabs" argument to use the "\toprule", "\midrule", and "\bottomrule" tags from the Latex "booktabs" package rather than using "\hline" for all horizontal lines.
  • Added "scalebox" argument to include a "\scalebox" clause around the tabular environment with the specified value used as the scaling factor.
  • Added "width" argument to allow specification of the width value in tabular environments such as "tabularx".
  • Added "X" as an allowed alignment value in the "align()" replacement function.
  • Changed the "print.xtable()" arguments to use "getOption()" to check the options for a default value. This was suggested since "print.xtable()" has a lot of arguments that the user will typically leave unchanged between tables.
  • Added an "is.null()" check on the "table.placement" argument.
  • Added examples using the new arguments to the vignette.

1.6-0 (2011-10-07)

  • Allow "table*" as a value for "floating.environment" in print.xtable().
  • Fix bug under which multiple logical columns were formatted incorrectly.
  • Stop with an error if "xtable.table" is used on a table with more than two dimensions.
  • Add some newlines to "Rd" file to prevent lines from extending off the page in the PDF version of the help files.
  • Changed the maintainer to "Charles Roosen".
  • Created an "xtable" project on R-Forge.

1.5-6 (2009-10-30)

  • Support caption at the top in the LaTeX longtable.
  • Use options()$OutDec for decimal mark.

1.5-5 (2009-03-24)

  • Added html.table.attributes to set the attributed of the tag for HTML tables.
  • Accommodated logicals by converting to characters.
  • Add an extra space at end of each line for LaTeX tables.
  • Fixed typographical error in documentation.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.8-2 by David Scott, 2 years ago


Browse source code at https://github.com/cran/xtable

Authors: David B. Dahl <dahl@stat.byu.edu>

Documentation:   PDF Manual  

Task views: Reproducible Research

GPL (>= 2) license

Imports stats, utils

Suggests knitr, lsmeans, spdep, splm, sphet, plm, zoo, survival

Imported by AICcmodavg, BEACH, BEQI2, BioGeoBEARS, BrailleR, CUFF, Correlplot, CovSelHigh, Crossover, DAMisc, EMA, EasyHTMLReport, HRM, IsoGene, JMbayes, MSBVAR, MplusAutomation, NNTbiomarker, OpasnetUtils, PopGenReport, RItools, RSDA, RecordLinkage, SIMMS, SciencesPo, SensMixed, ShinyItemAnalysis, SixSigma, StableEstim, StatDA, Stickbreaker, bea.R, canprot, clickR, condir, confidence, descr, dtwSat, dynr, fifer, gsrsb, hierarchicalDS, huxtable, inTrees, kutils, lfe, lsmeans, midrangeMCP, miscset, ncappc, pipe.design, pkgmaker, poliscidata, qmethod, reportRx, reproducer, robustlmm, sdcMicro, seasonalview, shiny, shinyHeatmaply, shinystan, sparkTable, spduration, stacomiR, stacomirtools, summarytools, survMisc, tab, userfriendlyscience, x.ent.

Depended on by A3, AmpliconDuo, DATforDCEMRI, FactoClass, IndependenceTests, LeLogicielR, LinRegInteractive, PIGE, RcmdrPlugin.Export, RcmdrPlugin.NMBU, TRSbook, TableMonster, bayesMCClust, compareGroups, etable, generalCorr, gsDesign, klausuR, likert, multilevelPSA, pamctdp, papeR, permPATH, quipu, reporttools, rplotengine, rtable, seqDesign, survSNP, surveillance, twang.

Suggested by AutoModel, BayesFactor, CALIBERrfimpute, CNVassoc, ClassDiscovery, EGRET, EloChoice, ExtDist, GenAlgo, HiveR, JoSAE, LSAmitR, MARSS, MPSEM, NMF, NPC, NlsyLinks, PMCMR, RSiena, RankAggreg, SBSA, SII, SeleMix, SeqFeatR, SharpeR, StMoMo, TailRank, Tcomp, TraMineR, TriMatch, afex, arsenal, ascii, attribrisk, bestglm, blockTools, boostr, caper, caschrono, chipPCR, coin, dpcR, drLumi, e1071, evtree, fbRanks, geex, geoknife, gets, hamlet, hdm, htmlTable, icarus, icd9, ifaTools, itsadug, knitrBootstrap, kyotil, matlib, mcmc, micEconCES, microplot, mixedMem, multcomp, nFactors, nimble, optmatch, ordinal, pedometrics, phangorn, protViz, qtutils, quanteda, rbamtools, rcdk, robustbase, rodeo, rscala, rtf, rtimicropem, sadists, soiltexture, sos4R, sparseHessianFD, sparseMVN, spdep, sqlutils, taRifx, texPreview, textreg, tukeytrend, waterData.

Enhanced by JM, pampe.

See at CRAN