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
2
votes
1 answer

Is it possible to set fig.scap for table (instead for figure) genrated by a code chunk?

I have a table generated by knitr code chunk. The table is printed using xtable. Its caption is set inside the xtable function. This label is too long to be displayed in the list of tables in the beginning of the document. Therefore I want to set a…
kamila
  • 122
  • 1
  • 2
  • 13
2
votes
1 answer

Adding section headers in between xtable figures in a loop

I am using knitr to generate a PDF writeup. I want to print a series of tables with section headers in between. I am doing this in an R code chunk. Unfortunately though, what happens is that the first header prints, then a figure, then the rest of…
Michael Discenza
  • 3,240
  • 7
  • 30
  • 41
2
votes
1 answer

Include label attribute into xtable header

Reproducible example: I have a data frame which has labelled variables using the sjmisc package, which works nicely together with dplyr since v0.4.2. library(dplyr) library(sjmisc) library(ggplot2) data("diamonds") df= tbl_df(diamonds) %>% …
user2030503
  • 3,064
  • 2
  • 36
  • 53
2
votes
0 answers

Shiny: passing reactive values to xtable options in renderTable

I am having a problem with a format of a table. Let's say I want to control the number of digits of a table with a numeric input. It seems that the options of the table are rendered when I launch the application but not with reactive values. is…
Nick
  • 46
  • 5
2
votes
0 answers

xtable inside of a for loop in Rmarkdown is printing {} in output when floating = FALSE

I am trying to create an Rmarkdown file with a loop to print several tables. For example, this Rmarkdown file: --- output: pdf_document --- ```{r, echo=FALSE, include=FALSE} library(dplyr) library(xtable) ``` ```{r, echo=FALSE,…
2
votes
1 answer

Unusual table order when using xtable in R

I am trying to print a number of x tables in a markdown document with some text in between. However, the output pdf dose not have the tables in the order that I had specified. I have attached the sample code and output below --- title: "Table…
2
votes
1 answer

R->TeX Table Package: after inputting data manually, SEs and stars are missing in output

Why isn't stargazer outputting standard errors and stars in the below table? How can I get stargazer (or another table package) to present the standard errors in parentheses below the coefficient, and present significance stars next to the…
Dr. Beeblebrox
  • 838
  • 2
  • 13
  • 30
2
votes
2 answers

Automating LaTeX reports with Brew, Pander and R

I am trying to write a brew template that takes a dataset, and produces a simple data dictionary. I want a separate page with the name of the var, and a frequency table for that var so I have this written so far: An R function that returns a…
Carl
  • 5,569
  • 6
  • 39
  • 74
2
votes
1 answer

R: How to set position-option in tabular via xtable?

Using xtable the following code \documentclass{article} \begin{document} <<>>= myData <- matrix(c(1,2,3,11,12,13,111,222,33),ncol=3,byrow=TRUE) colnames(myData) <- c("A","B","C") @ <>= library("xtable") xt <-…
JerryWho
  • 3,060
  • 6
  • 27
  • 49
2
votes
1 answer

define size of table in xtable

How can I define the size of table in xtable? I am using this code in knitr to render the table to PDF. I want my table to be square (length and width same) library(xtable) df <- data.frame(value1 = c(1,2,3), value2 = c(10,200,3000), value3 =…
d.putto
  • 7,185
  • 11
  • 39
  • 45
2
votes
1 answer

How do I bold a specific column and all column headers in xtable in knitr (print.xtable)

I am having difficulty understanding how to bold both a specific column and all the column headers using print.xtable
macrotourist
  • 73
  • 1
  • 4
2
votes
1 answer

xtable: extra column added and error using align argument

I'm having a hard time generating the LaTex format table I want using the xtable package. There are three things I'm trying to do: Not have the first column be the simply the numbered rows. Have the columns be a fixed width. Use the longtable…
Mike Edinger
  • 175
  • 1
  • 4
  • 11
2
votes
1 answer

xtable: change the color and thickness (table.attributes)

Really appreciate your help! I am generating LaTeX tables with R and the xtable package, like this: df <- cbind(c("SUNE", "WST"), c("Apr 01", NA), c("EXL", "VG"), c("Mar 18", NA)) out_table <- xtable(df) align(out_table) <-…
jonnie
  • 745
  • 1
  • 13
  • 22
2
votes
0 answers

Incorporating xtable with renderTable

I'm trying to get a basic xtable going and the math symbols are not showing up. I have the following snippets: Server.R output$FGR <- renderTable({ results <- as.data.frame(createOutput()$resultsFGR) colnames(results) <-…
user1357015
  • 11,168
  • 22
  • 66
  • 111
2
votes
2 answers

Formatting output with Knitr, ggplot2 and xtable

I am trying to achieve the following task with Knitr, ggplot2 and xtables: Generate several annotated plots of beta-distributions with ggplot2 Write the output in a layout such that I have a plot, and a corresponding summary Stats table following…
SGH
  • 313
  • 1
  • 2
  • 9