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

horizontal dashed or dotted lines in xtable

I wonder if there is a way to make some hlines in xtable dashed or dotted using command hline.after. I couldn't find a solution. MWE (Rnw): \documentclass{article} \usepackage{booktabs} \begin{document} <
jmjr
  • 2,090
  • 2
  • 21
  • 31
3
votes
1 answer

xtable caption alignment left aligned with table or centered (using knitr)

I'd like to align an xtable figure caption left adjusted with the table, or if that doesn't work, at least centered, because I think it looks kind of stupid a small table being centered and the corresponding caption being left aligned. Also, left…
jmjr
  • 2,090
  • 2
  • 21
  • 31
3
votes
2 answers

table* environment from xtable

If I do the following command: xtable(diamonds[1:5,1:4], label = 'tab:myTab', caption='This is my caption',align = c("rr|lr|r")) I get the following output: \begin{table}[ht] \centering \begin{tabular}{rr|lr|r} \hline & carat & cut & color &…
user2808302
3
votes
1 answer

Xtable two columns using longtable customizations

This is a continuation of a question I posted earlier. I have a code.Rnw file in RStudio which I knit into a code.tex file using knit("code.Rnw") command. I have a data frame that I am printing using the xtable command. In the example below, it is…
user2808302
3
votes
2 answers

Line breaks in xtable cells

I'm using xtable to automatically generate LaTeX tables and would like to force a line-feed/break within cells. This can be done using \newline within a cell, however I'm having trouble preventing xtable from substituting my backslashes (\) with…
slackline
  • 2,295
  • 4
  • 28
  • 43
3
votes
1 answer

R, knitr, xtable, using both add.to.row and hline.after

I’m trying to produce a table with xtable in R using knitr. I have inserted a header and extra \hlines. I’m using the add.to.row command to insert my header at the top, as well as midway through the table. I can’t seem to get the hline.after…
NotYourIPhone Siri
  • 715
  • 1
  • 8
  • 11
3
votes
1 answer

Error in applying a for loop to an xtable in knitr

I'm preparing a pdf using knitr that contains a table produced using xtable. I'm adding a bold typeface to certain cells in the table so I've written the following function: bold <- function(x, matrix){ x[] <- lapply(x, as.character) …
Matt
  • 541
  • 1
  • 4
  • 8
3
votes
1 answer

print.xtable messing up html tags

I face difficulties using print.xtable to insert a html table inside another table. DF=data.frame(A=c("a","b"),B=c("This is a text
x error
1
RockScience
  • 17,932
  • 26
  • 89
  • 125
3
votes
1 answer

Loops, knitr and xtable in rmarkdown to create unique tables in multiple reports

I'm revising my question in full. I realized it was long, and my point was getting lost. Here's what I need to do: Create automatic reports for schools that contain tables that compare their data to the district that school is in as well as the…
bfoste01
  • 337
  • 1
  • 2
  • 14
3
votes
1 answer

show html table (via xtable) in knitr-powered document

I am trying to figure out how to use xtable when creating html pages with knitr. My main reason to work with xtable is because I want to be able to rotate column names and/or rownames. This is my .rmd document: --- output: html_document --- ```{r,…
Peter Verbeet
  • 1,786
  • 2
  • 13
  • 29
3
votes
0 answers

xtable - how do I set both the column width and column text justification

I'm trying to create a Latex table with xtable. Some of my column names are rather long, so I decided to fix the width of the the respective columns. However, once I fix the width of the columns I lose the column justification. Simplified example:…
3
votes
1 answer

Sweave xtable show column header for rownames

I am using an xtable with the option "include.rownames =TRUE". How do I add a column header for the row names?
user1357015
  • 11,168
  • 22
  • 66
  • 111
3
votes
1 answer

Output a table with subtables in latex with xtable

I want to create a latex table with many different subtables. I basically want to generate a table with the answers from a survey. For example the table for the first question is: Q1 <- structure(c(6L, 14L, 20L, 15L, 2L, 3L, 12L, 25L, 7L, 1L, 2L,…
Ignacio
  • 7,646
  • 16
  • 60
  • 113
3
votes
1 answer

Can you merge cells in an xtable in R

I've got some data (the output of a ddply function) that I want to present in an xtable for use somewhere else. calqc_table<-structure(list(RUNID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), ANALYTEINDEX = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,…
PaulHurleyuk
  • 8,009
  • 15
  • 54
  • 78
3
votes
2 answers

Horizontal xtable on summary of data from read.csv

I've got a CSV file that looks like this: RTT,From,Req,Bytes,TTL 202,10.0.0.10,1,64,64 191,10.0.0.10,2,64,64 ... I am trying to produce a LaTeX summary() using library(xtable), like so: library(xtable) pings <- read.csv("pings.csv") s <-…
csl
  • 10,937
  • 5
  • 57
  • 89