xtable

R - Conditional row highlighting in HTML table created using xtable or kable

纵饮孤独 提交于 2019-11-29 07:02:27
问题 I'm pretty much a beginner at programmatically formatting R output, but I've got a basic understanding of knitr , xtable , Markdown, and Pandoc's ability to convert one markup format to another. What I want to do is write an R dataframe df to an HTML table, and apply a particular color to each row that meets a condition (e.g., df$outcome == 1 ). However, I'm not sure which package would accomplish this in a simple and efficient way, but from browsing a few table formatting threads (xtable

Combining several regression tables into one for use in xtable with Sweave in R

狂风中的少年 提交于 2019-11-29 03:00:52
问题 xtable in Sweave works awesome, but does one table per regression. You can feed it a data frame, too, so I have been manually rbind ing and paste ing results into data frames, but that doesn't seem very scalable. Is there a more automated/robust solution that works like xtable , but on multiple lm objects? Are all of the tables that I see in papers/books generated manually? Is there a better solution to my janky code that generates a data frame to feed to xtable ? library(reshape2) data <-

Customize xtable

我只是一个虾纸丫 提交于 2019-11-29 02:39:11
问题 I'd like to customize xtable for export into LaTeX. I know there are some questions abot xtable here, but I couldn't find the specific things I'm looking for. Here is an example of how my table might look like: my.table <- data.frame(Specifiers=c("","Spec1", "Spec2", "Spec3"), Values1 = c("N=10", 1.03, 1.71, 2.25), Values2 = c("N=20", 1.32, 1.79, 2.43)) colnames(my.table)[1] <- "" Which creates: Values1 Values2 1 N=10 N=20 2 Spec1 1.03 1.32 3 Spec2 1.71 1.79 4 Spec3 2.25 2.43 In fact, this

Using xtable with R and Latex, math mode in column names?

风流意气都作罢 提交于 2019-11-29 02:35:24
问题 I'm using xtable to compile tables from R automatically while compiling my TeX document. The question I have is how I get the variable names in the table (which in my case are the column names in a dataframe) to be in math mode. I have stored my results in the dataframe adf.results, and essentially what I want is colnames(adf.results) <- c(" ", "$m^r_t$", "$\delta p_t$", "$R^r_t$", "$R^b_t$", "$y^r_t$") but that simply inserts $m^r_t$ ... as the column names without interpreting them as being

knitr, R Markdown, and xtable: xtable tables within HTML table

為{幸葍}努か 提交于 2019-11-29 02:23:07
Suppose I want to print HTML tables using xtable, side-by-side. I tried doing this in an .Rmd file with: <table border = 1> <tr> <td> `r functionThatPrintsAnHTMLTableUsingxtable` </td> <td> `r functionThatPrintsAnotherHTMLTableUsingxtable` </td> </tr> </table> No dice. What am I doing wrong? Thanks. nograpes I think your code will work if you put results=asis in the chunk options. <table border = 1> <tr> <td> ```{r results='asis', echo=FALSE} library(xtable) data(tli) print(xtable(tli[1:20, ]),type='html') ``` </td> <td> ```{r results='asis', echo=FALSE} library(xtable) data(tli) print(xtable

Create a table in R with header expanding on two columns using xtable or any package

此生再无相见时 提交于 2019-11-29 02:22:50
I want to combine the tables from two dataframes and want to export that table to latex. The table that i want to create looks as follows. Note, the table below is created using excel. From xtable in R I was able to export the table for two individual stations. get the following for two stations T1 and T2. How can I combine the output of two stations to get the desired output as above? Station T1: > stT1 Observed-modeled |observed-modeled| Min. -1.5360000 0.0001891 1st Qu. 0.0002512 0.1633000 Median 0.3593000 0.5390000 Mean 0.8554000 1.0020000 3rd Qu. 1.6470000 1.6470000 Max. 5.5370000 5

R, knitr, xtable, alternating row colors

感情迁移 提交于 2019-11-28 20:11:44
问题 I'm trying to produce a table with xtable in R using knitr with alternating row colors. I can print a table in the PDF output but can't quite figure out the add.to.row command in the xtable manual along with the colortbl package. 回答1: This figure was produced using the code at the bottom. I hope you don't break your eyes detecting the light grey color (I almost have, on one of my screens). library(xtable) mydf <- data.frame(id = 1:10, var1 = rnorm(10), var2 = runif(10)) rws <- seq(1, (nrow

R: xtable caption (or comment)

十年热恋 提交于 2019-11-28 19:38:11
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? First, some mock data: x <- sample(LETTERS, 5, replace = TRUE) y <- sample(LETTERS, 5, replace = TRUE) z <- table(x, y) Now here's a somewhat clumsy solution, using print.xtable 's

Counts & Percentages in xTable, Sweave, R, cross tabulations

我的梦境 提交于 2019-11-28 19:18:11
问题 Edit: Building off of aL3xa's answer below, I've modified his syntax below. Not perfect, but getting closer. I still haven't found a way to make xtable accept \multicolumn{} arguments for columns or rows. It also appears that Hmisc handles some of these type of tasks behind the scenes, but it looks like a bit of an undertaking to understand what's going on there. Does anyone have experience with the latex function in Hmisc? ctab <- function(tab, dec = 2, margin = NULL) { tab <- as.table(tab)

How to remove the % lines in xtable table output by Knitr

谁说胖子不能爱 提交于 2019-11-28 17:26:08
问题 By using xtable and knitr, I add a table to my RMD document and export to PDF file. ```{r, results='asis'} library(xtable) xtable(matrixtable) ```` It looks great except there is a line % latex table generated in R 3.1.0 by xtable 1.7-3 package % Wed Jun 25 13:34:57 2014 How can I remove this line. I tried to set message=FALSE but it doesn't work. 回答1: The inclusion of the comment in the final table is defined by the comment argument to print.xtable the default value for this is getOption(