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
0
votes
0 answers

Nice looking rendering of "summaryDefault" objects in R/Knitr

I am trying to make some reports with Rmarkdown, and one of the things I would like to display in nice, formatted text is results of the summaryDefault type object. I have tried using Kable and XTables, but neither seems to be up to the task. With…
Stonecraft
  • 860
  • 1
  • 12
  • 30
0
votes
1 answer

How to add a caption to a resized table with scalebox in xtable?

I'm working on a R Markdown document. I've got a dataframe of this kind: library(tidyverse) library(xtable) df <- tibble(a = 1:10, b = 1:10, c = 1:10, d = 1:10, e = 1:10, f =1:10, g = 1:10, h = 1:10, i = 1:10) I'm using the xtable package to…
jandraor
  • 187
  • 1
  • 10
0
votes
1 answer

Align xtable columns based on dataframe column type R

I am using xtable in knitr to create tables and currently I left align all xtable columns because it is easy and repeatable. However, I am wondering if there is a way to align the xtable columns depending on the type of data in the dataframe column…
Prevost
  • 677
  • 5
  • 20
0
votes
1 answer

Fixing rounded R values in xtable in knitr

Has anyone come up with a solution to adjust rounded R values shown in a knitr document, either as stand along \Sexpr{} or through xtable? Typing?round returns Note that for rounding off a 5, the IEC 60559 standard is expected to be used, ‘go to the…
Prevost
  • 677
  • 5
  • 20
0
votes
1 answer

Adjustment of horizontal lines is not working in xtableList

I'm using the nice xtable package to create latex tables that are converted to PDF via Rmarkdown. To just have on horizontal line after the column names, the following is working fine: tt <- diag(5) print(xtable(tt),hline.after=0) To explain…
maxpe
  • 344
  • 2
  • 12
0
votes
1 answer

Not showing NAs in knitr::kable output as do xtable

I want to omit NAs in the output of knitr::kable output same as the xtable do (See kable and xtable outputs below). fm12anova <- structure(list(SOV = c("Days", "Residuals"), Df2 = c(1L, 178L ), Sum.Sq2 = c(162702.651909532, 405251.617480465),…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
0
votes
1 answer

R Sweave: output a very large table with linebreaks at the end of the page

I'm using R Sweave and wanted to begin my document with showing a sample of my table. My problem is, that my table has 39 variables and many rows. For the rows it isn't a problem, I can take only a few ones using sample_n, but I need to habe all my…
GaryDe
  • 492
  • 1
  • 5
  • 17
0
votes
2 answers

merge columns every other row using Sweave/R/Latex

I am writing a conference abstract booklet using R/Sweave. I have already made the program booklet for printing that contains the id, author, title only. Now I want to modify it to include the abstract (not for print). But abstracts are lengthy. My…
Robin Donatello
  • 415
  • 3
  • 12
0
votes
2 answers

How to convert from a matrix to a contingency table?

I have the following matrix matrix(c(1228,39,2,158,100,649,1,107,1,0,54,9,73,12,4,137), nrow=4) [,1] [,2] [,3] [,4] [1,] 1228 100 1 73 [2,] 39 649 0 12 [3,] 2 1 54 4 [4,] 158 107 9 137 And I would like to convert…
Dambo
  • 3,318
  • 5
  • 30
  • 79
0
votes
2 answers

R: convert decimal point to comma in xtable string (for LaTeX)

I'm using xtable to convert an R table into an object, which can then be printed as a LaTeX table. In this table, I need single numbers to be printed in different colors. Therefore, I already substituted these numbers before applying the xtable…
Johanna
  • 323
  • 1
  • 3
  • 10
0
votes
1 answer

Change heading and include bold font in xtable to .pdf from RMarkdown

I am a beginner with RMarkdown and LaTex, although enjoying creating reports in R! I have picked up some code to create the exact .pdf report I am after, although having difficulty with some aesthetics. My data is confidential but here is a replica…
user2716568
  • 1,866
  • 3
  • 23
  • 38
0
votes
1 answer

Trying to build a large table in R

I am trying to build a large table in R. Yes I have heard of the table() function - in fact, I've used it several times in the code below - but I am building this because I do not want to type table() 20 times a day. I plan on just exporting this…
0
votes
1 answer

How do I repeat column headers on subsequent pages AND colour alternating rows using xtable?

I am able to use longtable to get the column headers to repeat on subsequent pages, and I'm able to alternate row colour, but I can't figure out how to combine the two using add.to.row. Below is sample Markdown code that shows the two tables.…
GregRousell
  • 997
  • 2
  • 13
  • 23
0
votes
1 answer

xtable: how to only keep part of the tex output?

Consider this simple example data <- data.frame(string = c('one','two')) data # string # 1 one # 2 two I want to write this data.frame to a tex file. I can use xtable xtable(data) with TeX output % latex table generated in R 3.3.1 by…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
0
votes
1 answer

Not able to format dataframe using xtable

I have a dataframe and I want to display that into a R markdown HTML file. I am able to generate a table using Kable function of Knitr, but I wanted to change look and feel, like highlighting the header. as some suggested on Stackoverflow to use…