Questions tagged [xtable]

A function of an R package of the same name, used to convert an R object into an object that may be printed as a LaTeX or HTML table.

This function extracts tabular information from x and returns an object of class "xtable". The nature of the table generated depends on the class of x. For example, aov objects produce ANOVA tables while data.frame objects produce a table of the entire data.frame. One can optionally provide a caption (called a title in HTML) or label (called an anchor in HTML), as well as formatting specifications. Default values for align, digits, and display are class dependent.

The available method functions for xtable are given by methods(xtable). Users can extend the list of available classes by writing methods for the generic function xtable. These methods functions should have x as their first argument with additional arguments to specify caption, label, align, digits, and display. Optionally, other arguments may be present to specify how the object x should be manipulated. All method functions should return an object whose class if given by c("xtable","data.frame"). The resulting object can have attributes caption and label, but must have attributes align, digits, and display. It is strongly recommended that you set these attributes through the provided replacement functions as they perform validity checks.

The xtable package is a creation of David Dahl with contributions and suggestions from many others.

396 questions
6
votes
3 answers

How to remove "Standard Error" column from xtable() output of an lm on R/RSweave/LaTeX

I'm currently doing some data analysis on population data, so reporting the standard errors in the tables of parameter coefficients just doesn't really make statistical sense. I've done a fair bit of searching and can't find any way to customize the…
Lucas Spangher
  • 339
  • 2
  • 14
6
votes
1 answer

inset \footnote{} into header with xtable and tabular.environment

Can I control the add.to.row command in xtable to place an \footnote{} in the LaTeX table output header? This is how far I've gotten it. (I would like to find a solution using xtable and not `Hmisc') require(xtable) x <- matrix(rnorm(60), ncol =…
Eric Fail
  • 8,191
  • 8
  • 72
  • 128
5
votes
2 answers

Column alignment in xtable output

I'm using xtable to manage R output in Sweave. See code below: CC <- data.frame( y = c(449, 413, 326, 409, 358, 291, 341, 278, 312)/12, P = ordered(gl(3, 3)), N = ordered(gl(3, 1, 9)) ) CC.aov <- aov(y ~ N * P, data = CC , weights = rep(12,…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
5
votes
1 answer

Sort xtable() output by p-value from glm model summary

I'm modelling a lot of data for different companies, and for each company I need to identify quickly those model parameters that are most significant. What I would like to see is xtable() output for a fitted model that sorts all coefficients in…
Brandon Bertelsen
  • 43,807
  • 34
  • 160
  • 255
5
votes
1 answer

Can stargazer follow booktabs style?

I am quite in doubt about which table formatting package to use, being xtable and stargazerthe alternatives. I find Stargazer easier to understand when building tables - specially if a need to use column spanning. However, I do not know how to make…
5
votes
3 answers

In sweave, xtable, only rotate some column names

Lets say i want to make a table in sweave, like this: <>= library(xtable) df <- data.frame(Fish=1:5, Bird=11:15) rownames(df) <- 2013:2017 print(xtable(df), rotate.colnames =…
Jeppe Olsen
  • 968
  • 8
  • 19
5
votes
2 answers

header on each page of big table of xtable?

How do you put on a big table of xtable the table header on each page?, So that is easier to read the table the table between pages. I use the following in Sweave: test.big<- xtable(test,label="table",caption='test') align(test.big) <-…
Ricardo Rod
  • 8,453
  • 9
  • 27
  • 39
5
votes
1 answer

How to make xtable draw the vertical lines by default in a knitr document

I want knitr to produce tables with the vertical lines between columns by default. I understand that I can pass align argument to print the xtable. But that is repetitive, and the value of align is not the same for tables with different number of…
Rahul Gopinath
  • 808
  • 10
  • 24
5
votes
1 answer

xtable italics format for a column

I need to insert the species names in a table created by xtable in my Rnw file and I want to convert the relative column to italics format. Is it possible without any manual intervention? My call is: xtable(cklist, caption="Checklist...",…
bioglp
  • 75
  • 5
5
votes
0 answers

How can I label variables, data frame columns (full name + units) in such a way that plots, xtable, etc. will automatically use this information?

I have just become aware of the label function in the Hmisc package. Yet, as far as I can see, this function does not solve my problem as axis labels still need to be manually specified as xlab=label(var). I don't see any solution for producing…
5
votes
1 answer

xtable thead in html output

I am using xtable in R with knitr to produce some nice looking tables. I would like to use CSS that makes us of . Problem is that with xtable, I get wrapped in , but nothing else, so the HTML code from RMarkdown tables and xtables…
bytesinflight
  • 1,624
  • 2
  • 17
  • 28
5
votes
1 answer

Format html-output from R table like excel pivot w/ option "Do not repeat item labels"

I have casted (reshape2) a dataframe table with the following structure: Region | school |Region | school | Year1 | Year2 | ----------------------------------- |R1 | S1 | Value1| Value2 | |R1 | S2 | Value3| Value4 | |R1 | S3 …
Andreas
  • 6,612
  • 14
  • 59
  • 69
5
votes
2 answers

Including model specifications in xtable(anova(...))

I have a bunch of loglinear models, which, for our purposes will just be glm() objects called mx, my, mz. I want to get a nicely-formatted xtable of the analysis of deviance, so naturally I would want to perform xtable(anova(mx, my, mz, test =…
HamiltonUlmer
  • 2,389
  • 4
  • 19
  • 14
5
votes
1 answer

xtable + knitr set column width html

How can I set the column widths of individual columns in the knitr (Rmd) output of a code chunk using the xtable package? MWE ```{r setup, include=FALSE} library(xtable) ``` ```{r, results="asis", echo=FALSE} print(xtable(mtcars[1:2, 1:2]),…
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
5
votes
2 answers

xtable and header alignment

Is it possible to have a header alignment in xtable which is different from the alignment used in the rest of the table? In my case, I want my header to be center aligned, but the table itself should be right aligned.
hejseb
  • 2,064
  • 3
  • 18
  • 28