xtable

Extra curly braces when using xtable and knitr, after specifiying size

柔情痞子 提交于 2019-11-28 13:02:50
I'm creating a R Markdown document using knitr and am running into trouble using xtable to create a table. My table is very large and I'm trying to reduce the size using the size command in the print statement. The issue I'm running into is that the command seems to add two extra curly braces which show up in the PDF, one before the table and one after. Does anyone know a way to fix this? MWE: --- output: pdf_document: keep_tex: yes tables: true --- ```{r, results='asis', echo=FALSE} library(xtable) my.df <- data.frame(matrix(c(1:18),nrow=2)) glossaryprint <- xtable(my.df, caption="Summary of

Hiding NA's when printing a dataframe in knitr

大憨熊 提交于 2019-11-28 08:57:25
I'm trying to print a table in knitr from a data frame using xtable . The table in the example below has the dimensions 3x7 but the third row only has one value, in the second column. The rest of the cells in the third row are 'NA'. When I compile the document, is there a way to prevent knitr from printing the NA's in the third row, so instead of NA I just have blank space? It feels like this should be a simple solution but I can't work out where/how to hide the NA's. Is it a change I need to make to the data frame or is it an xtable or knitr option I need to change? Sample knitr code:

General guide for creating publication quality tables using R, Sweave, and LaTeX

强颜欢笑 提交于 2019-11-28 02:34:21
There are a range of tools available for creating publication quality tables using R, Sweave, and LaTeX. In particular, there are helper functions like latex in the Hmisc package, and xtable in the xtable package. I've also often written my own code so that I could have complete control over table formatting (e.g., see this example ). However, when preparing publication quality tables a range of issues often arise: how and when to apply numeric formatting how to precisely control alignment of columns and cells how to precisely control cell borders how to convert variable labels to variable

Control number of decimal places on xtable output in R

青春壹個敷衍的年華 提交于 2019-11-27 21:56:46
I am using Rmd file to create a report and I used xtable package to create the table. The output of the xtable shows the number of decimal places upto 2 digits. Is there a way to control the decimal places in xtable ? The sample code I used in Rmd file for the xtable is as follows: ```{r, results='asis', message=FALSE, echo=FALSE} source("../../R code/data analysis.R") library(xtable) library(plyr) table1 <- xtable(t3,caption="Table showing the Mean discharge and mean gage height on each year on each month",digits=NULL) print.xtable(table1,type="latex",comment = getOption("xtable.comment",

possible to create latex multicolumns in xtable?

梦想的初衷 提交于 2019-11-27 12:38:56
I am using xtable with R Markdown and knitr to produce .tex files that I call with \input{}. Works great, but I have not figured out how to create multicolumns like the one shown here . Does anyone know how to to this? So far I am using: tbl <- xtable(data, align="l r r r r r") colnames(tbl) <- c("Variable", "Mean", "Std Dev", "Mean", "Std Dev", "Difference") caption(tbl) <- c("Table Title") print(tbl, include.rownames=FALSE, caption.placement="top", booktabs=TRUE, type="latex", file="output.tex") I'd like to have a different grouping header over each "Mean" and "Std Dev" ("Treatment" and

R: xtable caption (or comment)

≡放荡痞女 提交于 2019-11-27 12:26:43
问题 I want to put a comment under a table printed out by xtable. I figured that the best option would be to use the "caption" option: xtable(tablename, caption="This is a caption") . But this is somehow putting in a "Table 1" automatically, so that the output looks like: Table 1: This is a caption. Is there any way to suppress this or any simpler way of putting in a comment simply as an additional last row in the table? 回答1: First, some mock data: x <- sample(LETTERS, 5, replace = TRUE) y <-

Extra curly braces when using xtable and knitr, after specifiying size

和自甴很熟 提交于 2019-11-27 07:24:54
问题 I'm creating a R Markdown document using knitr and am running into trouble using xtable to create a table. My table is very large and I'm trying to reduce the size using the size command in the print statement. The issue I'm running into is that the command seems to add two extra curly braces which show up in the PDF, one before the table and one after. Does anyone know a way to fix this? MWE: --- output: pdf_document: keep_tex: yes tables: true --- ```{r, results='asis', echo=FALSE} library

Hiding NA's when printing a dataframe in knitr

元气小坏坏 提交于 2019-11-27 02:09:08
问题 I'm trying to print a table in knitr from a data frame using xtable . The table in the example below has the dimensions 3x7 but the third row only has one value, in the second column. The rest of the cells in the third row are 'NA'. When I compile the document, is there a way to prevent knitr from printing the NA's in the third row, so instead of NA I just have blank space? It feels like this should be a simple solution but I can't work out where/how to hide the NA's. Is it a change I need to

General guide for creating publication quality tables using R, Sweave, and LaTeX

孤人 提交于 2019-11-26 23:50:18
问题 There are a range of tools available for creating publication quality tables using R, Sweave, and LaTeX. In particular, there are helper functions like latex in the Hmisc package, and xtable in the xtable package. I've also often written my own code so that I could have complete control over table formatting (e.g., see this example). However, when preparing publication quality tables a range of issues often arise: how and when to apply numeric formatting how to precisely control alignment of

Control number of decimal places on xtable output in R

拜拜、爱过 提交于 2019-11-26 20:49:41
问题 I am using Rmd file to create a report and I used xtable package to create the table. The output of the xtable shows the number of decimal places upto 2 digits. Is there a way to control the decimal places in xtable ? The sample code I used in Rmd file for the xtable is as follows: ```{r, results='asis', message=FALSE, echo=FALSE} source("../../R code/data analysis.R") library(xtable) library(plyr) table1 <- xtable(t3,caption="Table showing the Mean discharge and mean gage height on each year