knitr

Inserting blank spaces at the end of a column name in a table using pander

試著忘記壹切 提交于 2019-12-24 16:35:44
问题 I am trying to find a way of centering a column heading in a pander table using knitr to pdf in rmarkdwon, but keeping the column entries right justified. --- title: "Table Doc" output: pdf_document --- ```{r table, echo = FALSE} table1 <- anova(lm(Petal.Length ~ Species*Petal.Width, iris)) names(table1) <- c("DF", "Sum Sq", "Mean Sq", "*F*", "*p*") library(pander) pander(table1, justify = c("left", rep("right", 5))) ``` There is no way to align individual cells inside a table in pandoc

Presenting Zelig Logistic Regression in Knitr with Stargazer or Other Package

这一生的挚爱 提交于 2019-12-24 16:26:37
问题 Stargazer appears to take most Zelig model objects except logistic regression: m1 <- zelig(voted ~ . - weight_full - by, weights = mydata$weight_full, data=mydata, model="logit", cite = FALSE) I receive the following warning from the above code: # Error in envRefInferField(x, what, getClass(class(x)), selfEnv) # ‘result’ is not a valid field or method name for reference class “Zelig-logit” Anyone have any alternatives for presenting such a model in a regression output table using Knitr to

r markdown error resulting from math in figure caption

醉酒当歌 提交于 2019-12-24 15:35:35
问题 I had an R markdown document that was working perfectly until I added a caption with latex math. Now I get the error: ! Argument of \reserved@a has an extra }. \par l.75 \end{verbatim}} pandoc: Error producing PDF from TeX source Error: pandoc document conversion failed with error 43 Execution halted The code below produces the error in Rstudio, Version 0.99.896, using knitr with pdflatex. Thanks!! --- title: Title goes here author: Names go here date: "\today" output: pdf_document: fig

how to combine multiple html (kable) tables into one image?

心已入冬 提交于 2019-12-24 15:15:19
问题 I would like to combine several kable tables into one single image. Something like: library(knitr) library(kableExtra) dt <- mtcars[1:5, 1:4] # first table table1 <- kable(dt, format = "html", caption = "Demo Table") %>% kable_styling(bootstrap_options = "striped", full_width = F) %>% add_header_above(c(" ", "Group 1" = 2, "Group 2[note]" = 2)) %>% add_footnote(c("table footnote")) # second table table2 <- kable(dt, format = "html", caption = "Demo Table") %>% kable_styling(bootstrap_options

add logo only on first (main) slide in ioslides RStudio

不羁的心 提交于 2019-12-24 13:06:59
问题 I'm using ioslides (rmarkdwon) in RStudio to create the presentation from R. I would like to add the logo, but only to the first slide (main) which renders this information: --- title: "Presentation" author: "Tom Hanks" output: ioslides_presentation logo: logo.jpg --- I don't want the logo in the bottom-left footer of each slide. Can anyone tell me how to switch it off? 回答1: You could modify the ioslide template to remove the repetition of the logo on each page. Download the template on the

Why does RStudio show the manually knitted pdf wrong?

落花浮王杯 提交于 2019-12-24 11:44:59
问题 I'm running the latest RStudio (0.97.551) and R (3.0.1) version on Mac OS X Mountain Lion 10.8.4. I have the following two files: test.Rnw \documentclass{article} <<set-options, echo=FALSE>>= options(replace.assign=TRUE) opts_chunk$set(external=TRUE, cache=TRUE, echo=FALSE, fig=TRUE) read_chunk('chunks.R') @ \begin{document} \section{Graphics} <<chart, fig.height=4>>= @ \end{document} and chunks.R ## @knitr chart library(ggplot2, quietly=TRUE) Sys.sleep(3) p <- ggplot(mtcars, aes(wt, mpg)) +

Printing linebreaks in HTML kable table

▼魔方 西西 提交于 2019-12-24 11:41:40
问题 When creating tables using kable , is there a way to generate a line break (ie < br > ) when string in a data.frame ' dt' has \n ? For example, here: library(data.table); dt <- fread("https://s3.amazonaws.com/assets.datacamp.com/blog_assets/prince_raw_data.csv") dt <- dt[301:303,2:6] #take three songs only library(knitr); library(kableExtra) kable(dt); # use this line to view it: dt %>% kable %>% kable_styling() This relates to Automated nicely formated book of lyrics from data.frame using

Error producing PDF from TeX source Error: pandoc document conversion failed with error 43 Execution halted

佐手、 提交于 2019-12-24 11:36:12
问题 I am new to R and have been trying to write my project report in R markdown. However I am facing issues. I tried implementing solutions present on stack overflow as well as other websites, but I have not been able to make progress. Details: R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut" RStudio Version 0.99.441 – © 2009-2015 Mac OS X Yosemite version 10.10.5 Installed pandoc 1.15.0.6 https://github.com/jgm/pandoc/releases/tag/1.15.0.6 The MacTeX-2015 Distribution from http://tug.org

Customize error message when compiling PDF

孤人 提交于 2019-12-24 11:27:44
问题 Given the following R knitr document: \documentclass{article} \begin{document} <<data>>= opts_chunk$set(comment = NA) # omits "##" at beginning of error message x <- data.frame(x1 = 1:10) y <- data.frame() @ <<output_x>>= if (nrow(x) == 0) stop("x is an empty data frame.") else summary(x) @ <<output_y>>= if (nrow(y) == 0) stop("y is an empty data frame.") else summary(y) @ \end{document} As expected, the last chunk returns an error with the custom message. The compiled PDF looks a little

How to group columns in R markdown?

与世无争的帅哥 提交于 2019-12-24 08:47:19
问题 I am trying to generate a table using kable and saving the output as a markdown. I am later using pandoc to convert markdown to pdf. For my table I would like to group my table columns into two groups. It seems that this could be achieved using the kableExtra "add_header_above" function, but unfortunately the output cannot be stored as markdown. Is there a way to group columns using markdown? I am pasting my dummy code below. Appreciate all comments and suggestions. library(knitr) library