xtable

How to display numbers in scientific notation in ASCII tables?

喜夏-厌秋 提交于 2019-12-12 10:43:44
问题 I am trying to display extremely small numbers (<1E-12) in an ASCII table. (Believe me, I can't find any alternative.) So far I've tried stargazer and xtable. Neither of them seems to work. I can display the numbers in scientific notation with xtable in HTML, but not ASCII. Stargazer seems not have the option to display numbers in scientific notation. Below is an example: library(stargazer) example <- data.frame(parameter = letters, value = runif(26, min = 1E-14, max = 5E-14)) stargazer

Adjust row height xtable R

折月煮酒 提交于 2019-12-12 08:44:32
问题 There are couple of helpful posts round dealing with xtable but no one deals with this as far as my search abilities go. I would like to adjust row height in xtable (print). I'm printing a data.frame. print(xtable(...),...) Please note that I'm already using add.to.row addtorow <- list() addtorow$pos <- list() addtorow$pos[[1]] <- c(0) addtorow$command <- c(paste("\\hline \n","\\hline \n",sep="")) So what I would like to do is to widen the upper row space: I have tried all kind of things but

hmisc::latex tables open in external xdvik window instead of being inserted into the pdf output document

纵饮孤独 提交于 2019-12-11 12:46:46
问题 Since our update to R2.15.1, the tables in my lyx documents that result from calls to the latex function (package Hmisc) open in an external xdvik-window instead of being inserted in the pdf-document that I am compiling. On the contrary, the tables produced with xtable and the graphs produced with ggplot do appear where they belong in the document. The chunk header for the latex call is <<Specs,tidy=F,results='asis',eval=F>>= and the chunk is then referred to multiple times with e.g. <

xtable highlighting: \rowcolor shifted down one row

女生的网名这么多〃 提交于 2019-12-11 10:18:16
问题 I am following this example in an attempt to add highlighting to rows of a LaTeX table created by xtable . In my version, I want to add highlighting to rows conditional upon column c having a value of 1. Here's my R code to generate the table. <<example>>= # create data frame my.df=data.frame(a=c(1:10),b=letters[1:10],c=sample(c(0,1), 10, replace=TRUE)) # identify index of rows to highlight row.i.1 <- which(my.df$c==1) print(xtable(my.df), only.contents=TRUE, include.rownames=FALSE, include

R to latex - Coloring numbers automatically

泄露秘密 提交于 2019-12-11 09:08:28
问题 I have a (long) R matrix. eg: matrix <- matrix(rexp(200, rate=.01), ncol=4) I would like to find a way to colour, for instance, the 15% more important numbers of each column, BEFORE doing the latex extraction as follow: print(xtable(matrix, align = c("r","r","r","r","r")), type = "latex", floating = FALSE, tabular.environment = "longtable") Any idea? 回答1: I finally found a dirty solution matrix <- as.data.frame(matrix(rexp(200, rate=.01), ncol=4)) Set the loop for(i in 1:length(matrix[1,])) {

apsrtable for sarlm class

江枫思渺然 提交于 2019-12-11 06:23:25
问题 I love apsrtable() , and have found it somewhat simple to extend to other classes (in particular, I have adapted it for mlogit objects. But for some reason, the apsrtableSummary.sarlm() function doesn't work quite like other hacks I have written. Typically, we need to redefine the coefficients matrix so that apsrtable() knows where to find it. The code for this is "apsrtableSummary.sarlm" <- function (x){ s <- summary(x) s$coefficients <- s$Coef return(s) } We also need to redefine the

Show multiple footnotes in xtable

廉价感情. 提交于 2019-12-11 06:19:50
问题 My question is very similar to this one on showing footnotes in xtable , although the suggested updated solution isn't working for me. I presume this is because I am missing something in my own setup, hence the separate question. I don't think the issue is what is described in this question, as I am using the sanitize.text.function in the print call rather than the xtable call. Below is an image of the PDF output. As can be seen, the actual footnote text does not appear in the PDF output,

xtable - background colour of added rows

白昼怎懂夜的黑 提交于 2019-12-11 04:05:41
问题 I'm trying to make a table with inserted summary rows using xtable and knitr. I'd like to have these inserted lines in a different colour. Using the add.to.row option, I've managed to either insert the lines or change the colour, but not both at the same time. The reason I'm inserting the rows within xtable, rather than ahead of time, is that I want the "total" row to be spread over two columns due to its length in my original dataset. So the required solution would have both multicolumn

R/Sweave/Latex - Place comment in table (xtable)

浪尽此生 提交于 2019-12-11 02:25:39
问题 I created a table using R and sweave in LaTeX. A sweave example: \documentclass{article} \begin{document} \SweaveOpts{concordance=TRUE} <<label=tab1, echo=FALSE, results=tex>>= library(xtable) employee <- c('John Doe','Peter Gynn','Jolie Hope') salary <- c(21000, 23400, 26800) mData <- data.frame(employee, salary) print(xtable(mData, caption = "Salary", align="ccc"), caption.placement="top", hline.after = c(c(-1, 0), nrow(mData)), include.rownames=FALSE) @ \end{document} The basic LaTeX

Replace accents in string vector with Latex code

让人想犯罪 __ 提交于 2019-12-10 19:29:12
问题 Define: df <- data.frame(name=c("México","Michoacán"),dat=c(1,2)) s.t. > df name dat 1 México 1 2 Michoacán 2 When I print this table to a .tex file using xtable the accented characters get garbled, which is no surprise. I would like to replace accents with proper Latex formatting e.g.: > df name dat 1 M\'{e}xico 1 2 Michoac\'{a}n 2 Please note in real dataset there are many different names with different accented letters but all with same type of accent (i.e. foward-slash), so the only thing