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
2 answers

R describe and R Markdown

I'd like to describe my data table in a R Markdown file using xtable(data, type='html') But none of the packages I looked so far seem to be compatible with xtable in html setting, f.i. Hmisc::describe,reporttools::tableNominal. Does anyone have a…
Joanne Demmler
  • 1,406
  • 11
  • 31
3
votes
0 answers

Get row.name of R Shiny tableOutput on hover

I would like to build a reactive input for R shiny that returns the row.name of a table row on hover. In R Shiny, the table is made with renderTable and output through tableOutput. This should work similar to the already built clickID and hoverID…
JayCo
  • 784
  • 7
  • 22
3
votes
1 answer

Change row names of a table obtained from a lm regression using xtable function

I obtained a summary table of a regression with couple variables. The code I used was this: stock = dyn$lm(y1 ~ x1 +lag(x2, -1) + x2 + x3 +x4) print(xtable(stock)) which gave me the following output: % latex table generated in R 3.0.1…
cactussss
  • 705
  • 2
  • 6
  • 10
3
votes
1 answer

xtable() to preserve latex function in R

I'm producing a series of tables in R that will include fractions once I report them in latex. To do this, I'm using the paste() function to apply the fraction command in r, however when I xtable it, it loses the "\f" in the beginning. Below is…
coding_heart
  • 1,245
  • 3
  • 25
  • 46
3
votes
1 answer

xtable rownames using R

I am using R and LaTeX and the xtable package for tables. I am a little puzzled why my specified rownames aren't showing up in my tables. Here's an example: \documentclass[a4paper,…
hejseb
  • 2,064
  • 3
  • 18
  • 28
3
votes
1 answer

Removing rownames but keeping &

In xtable, is there any way to print a latex table without rownames, but while keeping & on the left hand side? I also don't want to set the rownames to NA in my data matrix to achieve this feat. Example: require(xtable) o <-…
Jase
  • 1,025
  • 1
  • 9
  • 34
3
votes
1 answer

Is it possible to to export from reporttools?

I am using tableNominal{reporttools} to produce frequency tables. The way I understand it, tableNominal() produces latex code which has to be copied and pasted onto a text file and then saved as .tex. But is it possible to simple export the table…
user702432
  • 11,898
  • 21
  • 55
  • 70
3
votes
1 answer

Over-ride rownames renaming of duplicates with xtable

I would like xtable to NOT over-ride my duplicated rowname entries. Consider the following MWE: > require(xtable) > foo <- matrix(0, 2,2) > rownames(foo) = rep("bar", 2) > foo [,1] [,2] bar 0 0 bar 0 0 > xtable(foo) % latex table…
Christopher Aden
  • 757
  • 6
  • 21
2
votes
0 answers

How to include output from etable() of fixest package as latex regression table into markdown as html output?

I would like to include the regression output from etable(feols(fml = formula, data = data, cluster = ~cluster)) as latex regression table into an rmarkdown creating an html output. My regression function at the moment is this one: regression <-…
tiny
  • 129
  • 6
2
votes
2 answers

xtable output for a list of tables

I've a list of tables and want to sweave it for LaTex output. Here is the code: Data <- esoph[ , 1:3] library(plyr) combos <- combn(ncol(Data),2) TabelFn <- function(x) { Table <- addmargins(table(Data[, x[1]], Data[, x[2]])) return(Table) …
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
2
votes
0 answers

knitr xtable with long head note too long, stretch out the entire table

I'm new to knitr and Latex stuff, so this may be a very naive question, but I failed to find a correct answer. I'm doing empirical research that sometimes, we need to add headnotes as instruction for a complex table. Below is the code I'm currently…
Jia Gao
  • 1,172
  • 3
  • 13
  • 26
2
votes
1 answer

custom table for Rmarkdown pdf

I have a table as below (dput at the end) # A tibble: 35 x 5 # Groups: year [1] school_id class_id year variable value 1 123 1 2020 sex_numerator_male …
user5249203
  • 4,436
  • 1
  • 19
  • 45
2
votes
1 answer

How to save formatted table output as a .png?

```{r, results='asis'} library(xtable) ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) lm.D9 <- lm(weight ~…
Adrian
  • 9,229
  • 24
  • 74
  • 132
2
votes
1 answer

Is there a way to create a LaTex half matrix in R?

I am trying to use the xtable package to create a print-quality half matrix in R. I can create the full symetric matrix with no problem but when I extract only the lower triangle matrix, I get the error shown…
Jamie
  • 555
  • 3
  • 14
2
votes
1 answer

set different Digits in xtable

I thave a data set like mtcars and I would like to print it using xtable with digits =2 but the column carb I want to see the values with out digits xtable(head(mtcars), digits =2) Expected Results, please see the last column % latex table…
Seyma Kalay
  • 2,037
  • 10
  • 22