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

adding rows or boldify single row.names with print.xtables – add something in between rows?

I try to use print.xtable add.to.row to get table formatted like this: sports share of ballers 22.3 share of skiers 4.6 addiction share of smokers 20.3 share of drinkers 6.6 My R table does contain the additional row.names even if…
Matt Bannert
  • 27,631
  • 38
  • 141
  • 207
5
votes
1 answer

How can I omit interactions using stargazer or xtable?

Is it possible to omit interactions in stargazer using the omit option? Normally I would write the variable name into the omit=c('varname') but in the case of an interaction I do not know what to write. Any hints on that? How do you solve this…
Tom
  • 115
  • 1
  • 6
4
votes
3 answers

How to detemine the coding of accents?

This question is related to this previous one on how to replace accented strings like México with equivalent Latex code M\'{e}xico. My problem here is slightly different. I am using a third party database with string variables with Spanish accents…
Fred
  • 1,833
  • 3
  • 24
  • 29
4
votes
1 answer

print.xtable only displays, doesn't save to disk

Is anyone else having this problem? > d <- data.frame(x=1:5, y=6:10) > print(d, type="html", file="d:/delete/test5.html") x y 1 1 6 2 2 7 3 3 8 4 4 9 5 5 10 My R version is version 2.12.2 and xtable version is xtable_1.5-6.
Tom
  • 4,860
  • 7
  • 43
  • 55
4
votes
0 answers

How to get xtable to not ignore whitspace or to align decimal points respectively?

I'm about to write a function that yields both a screen output and a LaTeX/PDF-output of lists of regression tables and have problems with the decimal point alignment of the latter. From this toy table regmat, 1 2 …
jay.sf
  • 60,139
  • 8
  • 53
  • 110
4
votes
1 answer

how to flip a regression table in stargazer?

I would like to "flip" the row/columns in a regression table. The latest stargazer manuals says that now the flip argument also works with regression tables (previously it only worked with summary stats). However I am unable to make it work. Here…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
4
votes
3 answers

Align xtable caption left in knitr

I have read a bunch of different posts on justifying xtable tables left but I cannot find details/work out how to make the caption justify left as well. Below is a reproducible example which justifies the table left but leaves the caption centred.…
Robin
  • 389
  • 5
  • 19
4
votes
0 answers

xTable doesn't produce a table in R markdown

I am trying to get xtable to insert a table into an R markdown pdf document I'm working on. For some reason, I can't even get the examples from the documentation to reproduce. Instead, the output puts each individual cell on a new line. I've…
4
votes
1 answer

Send email from outlook by including dataframe as table in R

I have a dataframe as shown below. I am then converting the dataframe into an html table. # Use RDCOMClient to send email from outlook library(RDCOMClient) # Use xtable to convert dataframe into html table library(xtable) # Create dataframe df <-…
Code_Sipra
  • 1,571
  • 4
  • 19
  • 38
4
votes
0 answers

Wrapping xtable tablenotes

Is there a definitive way to add table notes to an xtable that will wrap if the tablenote is longer than the width of the table? I have referenced this question here which proposes splitting long table notes into multiple lines and adding it to…
Prevost
  • 677
  • 5
  • 20
4
votes
1 answer

How to retain date/time format in xtable for an email

I am looking to email a nicely formatted table from R using xtable. I found this thread explaining how to email an xtable easily, which works and the table looks great. However each time I do my date/time columns convert to numeric. My email…
Jamison
  • 73
  • 2
  • 8
4
votes
2 answers

How to write numbers in scientific notation in R

I am wondering if there is a way to write 0.000523 in scientific notation ( 5.23x10-4) in R. I am using the xtable command to write a table into latex.
R. Saeiti
  • 89
  • 3
  • 11
4
votes
1 answer

Add two commands to the add.to.row arguments in xtable

I have used the two answers below to add colors to alternating rows in xtable or to add a footer to a long table, but I need to figure out how to do both. (1) How to only show table caption once in "list of table" for a table split onto multiple…
user3357059
  • 1,122
  • 1
  • 15
  • 30
4
votes
1 answer

How does pandoc parse latex code in a .md file?

I am using Rstudio with knitr/rmarkdown/pandoc/latex to render .Rmd code to pdf. I have been struggling with certain latex code being rendered exactly as expected while very slightly different code ends up not being parsed correctly, which results…
4
votes
4 answers

Print HTML or Word table in knitr so that whitespaces in strings are respected

Using knitr and Rstudio, I'm trying to print a dataframe to HTML or Word, so that the leading whitespaces in versicolor, will push versicolor to the right. #data library(knitr ) library(xtable) df <- iris[c(1,51),c(5,1)] df$Species <-…
Rasmus Larsen
  • 5,721
  • 8
  • 47
  • 79