xtable

xtable caption alignment left aligned with table or centered (using knitr)

怎甘沉沦 提交于 2019-12-10 18:34:39
问题 I'd like to align an xtable figure caption left adjusted with the table, or if that doesn't work, at least centered, because I think it looks kind of stupid a small table being centered and the corresponding caption being left aligned. Also, left aligning both table and caption is not optimal. It should be possible using latex.environments = "left" , but I get an error message, just like in this post. I don't think the problem lies in the referencing, because I get the same error message with

How to convert Afex or car ANOVA models to lmer? Observed variables

有些话、适合烂在心里 提交于 2019-12-10 18:24:33
问题 In the afex package we can find this example of ANOVA analysis: data(obk.long, package = "afex") # estimate mixed ANOVA on the full design: # can be written in any of these ways: aov_car(value ~ treatment * gender + Error(id/(phase*hour)), data = obk.long, observed = "gender") aov_4(value ~ treatment * gender + (phase*hour|id), data = obk.long, observed = "gender") aov_ez("id", "value", obk.long, between = c("treatment", "gender"), within = c("phase", "hour"), observed = "gender") My question

Problems cross referencing in LaTex with knitr and xtable

ε祈祈猫儿з 提交于 2019-12-10 15:45:33
问题 I am currently working with R Studio to produce PDF documents with R/knitr in LaTex. Within these documents I want to present part of my results in tables that I want to refer to in the text. I produce these tables using the xtable package within R and it is working perfectly and giving me the right tables. So far so good but when it come to referencing I ran into some troubles. At the moment the resulting PDF output refers to the section in which the table lies. I searched around in some

How can I include hyperlinks in a table within an Sweave document?

若如初见. 提交于 2019-12-10 13:33:15
问题 I have a data frame containing hyperlinks that I would like to present as clickable links using Sweave . I know about xtable , but am not sure how to use it to treat the contents of a data frame as LaTeX commands. 回答1: One strategy is to use the sanitize.text.function from the print function in xtable . Setting sanitize.text.function = function(x){x} causes print simply to echo the contents of the data frame for later interpretation by LaTeX: \documentclass{article} \usepackage{hyperref}

Combining two tables and adding a header for each table in R

妖精的绣舞 提交于 2019-12-09 20:27:55
问题 I would like to display results of two regression analyses next to each other, let's say a logistic and a COX regression. Variables are presented in rows and corresponding data for p, OR/HR and confidence interval in columns. So, the column names don't match: it's OR on the left, HR on the right. I tried cbind, but I'm encountering the following problems: (1) What if one variable (row) is only present in one table due to variable selection? In that case, there would have to a blank row in the

Creating a latex table from ftable object in R

£可爱£侵袭症+ 提交于 2019-12-09 04:31:16
问题 Let me create some data before I ask my question. my.data <- data.frame(A = sample(seq(1,100,by=5),10,replace=TRUE),W = rnorm(10),X =sample(1:10),Y = sample(c("yes", "no"), 10, replace = TRUE),Z=sample(c('a','b','c','d'),10,replace=TRUE)) attach(my.data) my.d <- xtabs(W~Z+Y+A);my.d table.data <- ftable(my.d) result1 <- round(table.data,2) result1 looks like .. A 6 11 16 26 71 76 86 91 Z Y a no 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 yes 0.00 0.56 0.00 0.00 0.00 0.79 0.00 0.01 b no 0.61 0.00

Include dimension names in row and column headers for LaTeX-formatted contingency table

泪湿孤枕 提交于 2019-12-08 15:29:16
问题 If the categories of the attributes in a contingency table are mere numbers, using only these numbers as column/row header is not enough -- a description what the numbers mean is called for. The picture below shows the cross-classification of household size vs. number of foreigners in a household sample: Does anyone have experience in producing such tables using R+LaTeX? 回答1: I have a rather hackish solution of my own, but I'd like to see other approaches, too. Of course, it would be nice if

R: output a pivot-like table with subtotals

五迷三道 提交于 2019-12-07 06:12:32
问题 I'm trying to make a cross tabulation in R, and having its output resemble as much as possible what I'd get in an Excel pivot table. The objective is to replace a report made manually with Excel and Word with one automated with R Markdown; data wrangling and charts have been already taken care of but some tables are missing. So, given this code: set.seed(2) df<-data.frame("ministry"=paste("ministry ",sample(1:3,20,replace=T)),"department"=paste("department ",sample(1:3,20,replace=T)),"program

sorting a table for latex output with xtable

十年热恋 提交于 2019-12-07 03:54:02
问题 I´m trying to produce a sorted table and export in to latex. However it seems xtable cannot cope with sorted tables. Suggestions? a<-sample(letters,500,replace=T) b<-table(a) c<-sort(table(a),decreasing=T) xtable(b) xtable(c) //M 回答1: Pretty easy: sort() does not return a table, but an array. Use as.table() to solve your problem : a<-sample(letters,500,replace=T) b<-table(a) class(b) c<-sort(table(a),decreasing=T) class(c) d <- as.table(c) class(d) xtable(d) 来源: https://stackoverflow.com

Longtable in a knitr (PDF) document: using xtable (or kable)

纵饮孤独 提交于 2019-12-07 00:23:03
问题 I am new to knitr and I have had some very basic latex knowledge in the past, so I googled already hoping to find a solution that was already posted somewhere. However, I was not able to solve my problem. I am hoping someone will be kind enough to provide help. I have a data frame of 14 columns and many rows, let's say 60. Using the data I need to produce a PDF report in landscape layout and present this data frame as a table there. The closest solution I found is here at tex.stackexchange