knitr

Save knitr::kable() output to html file R

隐身守侯 提交于 2021-02-20 16:15:12
问题 I have a knitr_kable output that I want to save as an HTML document from R. I need this to run automatically from my R script with no human involvement. For example: dt <- mtcars[1:5, 1:6] kable(dt, "html") %>% kable_styling(bootstrap_options = c("striped", "hover")) This has html output but the class is knitr_kable so I can't write it to a table or html file because it cannot be coerced to a dataframe. class(kable(dt, "html")) [1] "knitr_kable" Does anyone have a method for saving one of

Placing table next to plot in R Markdown (to pdf / latex)

霸气de小男生 提交于 2021-02-20 03:55:07
问题 Is it possible to place a table generated with the xtable (or alternatively the pander ) package and a generated plot side-by-side in R markdown knitting to pdf while the rest of the document is not in columns? The following simple example hopefully illustrates the idea: \begin{multicols}{2} ```{r} plot(cars) ``` ```{r, results='asis'} library('xtable') print(xtable(head(cars,5)), type = "latex") ``` \end{multicols} However, this does not produce the plot. I know that solutions exist using

Generalized Linear Model output through texreg

为君一笑 提交于 2021-02-19 06:15:48
问题 I can use texreg to get beautiful output of glm to be used for knitr . Sometimes we need to convert the output of glm back to response using inverse link. I wonder how to get inverse link output with texreg . Something like texreg(exp(glm.D93)) . counts <- c(18,17,15,20,10,20,25,13,12) outcome <- gl(3,1,9) treatment <- gl(3,3) d.AD <- data.frame(treatment, outcome, counts) glm.D93 <- glm(counts ~ outcome + treatment, family = poisson()) library(texreg) texreg(glm.D93) which produces \begin

Generalized Linear Model output through texreg

余生长醉 提交于 2021-02-19 06:15:14
问题 I can use texreg to get beautiful output of glm to be used for knitr . Sometimes we need to convert the output of glm back to response using inverse link. I wonder how to get inverse link output with texreg . Something like texreg(exp(glm.D93)) . counts <- c(18,17,15,20,10,20,25,13,12) outcome <- gl(3,1,9) treatment <- gl(3,3) d.AD <- data.frame(treatment, outcome, counts) glm.D93 <- glm(counts ~ outcome + treatment, family = poisson()) library(texreg) texreg(glm.D93) which produces \begin

Generalized Linear Model output through texreg

痞子三分冷 提交于 2021-02-19 06:15:09
问题 I can use texreg to get beautiful output of glm to be used for knitr . Sometimes we need to convert the output of glm back to response using inverse link. I wonder how to get inverse link output with texreg . Something like texreg(exp(glm.D93)) . counts <- c(18,17,15,20,10,20,25,13,12) outcome <- gl(3,1,9) treatment <- gl(3,3) d.AD <- data.frame(treatment, outcome, counts) glm.D93 <- glm(counts ~ outcome + treatment, family = poisson()) library(texreg) texreg(glm.D93) which produces \begin

How to set a theme when knitting RMarkdown to HTML?

北城以北 提交于 2021-02-19 03:50:06
问题 I have not been able to figure out how to set a knitr theme when converting RMarkdown to HTML. I have tried code such as > opts_knit$set(out.format = "html") > opts_chunk$set(highlight = TRUE) > knit_theme$set("olive") That does not affect the html output. I have tried this code before knitting the Rmd file as well as inside the first chunk. 回答1: Put a css file with the same name as your R file, but extension css, into the directory. Or see http://www.rstudio.com/ide/docs/authoring/markdown

Change font size for all inline equations R markdown

六月ゝ 毕业季﹏ 提交于 2021-02-18 12:37:05
问题 I am creating a r-markdown file and using knitr to convert to HTML. When I inline an equation such as X_1,...,X_n \sim N(0,1) it gets converted to HTML output as this . The math text is oversized relative to the plain text font. I can correct this for a single equation with \small X_1,...,X_n \sim N(0,1) . However, I would prefer not to type \small hundreds of times throughout a document. Does anyone know how to correct this with a single settings change or modification so it's applied to all

Change font size for all inline equations R markdown

折月煮酒 提交于 2021-02-18 12:37:01
问题 I am creating a r-markdown file and using knitr to convert to HTML. When I inline an equation such as X_1,...,X_n \sim N(0,1) it gets converted to HTML output as this . The math text is oversized relative to the plain text font. I can correct this for a single equation with \small X_1,...,X_n \sim N(0,1) . However, I would prefer not to type \small hundreds of times throughout a document. Does anyone know how to correct this with a single settings change or modification so it's applied to all

Knitr: one plot per .tabset in for-loop

旧时模样 提交于 2021-02-18 12:17:08
问题 Long story short, I'm trying to use knitr to dynamically create separate tabsets and render a plot within each tabset. Below is a description of my failed attempts. I would appreciate a solution, but I suspect I'm just not understanding the fundamental way in which knitr renders output. So if you could point me to resources or provide some conceptual guidance, that would also be appreciated. Dynamically creating the tabsets themselves is easy. Here is my .R file #' --- #' title: #' author: #'

Does rmarkdown allow captions and references for code chunks?

…衆ロ難τιáo~ 提交于 2021-02-18 11:09:40
问题 Is there a trick for captioning and referencing a chuck of code in rmarkdown (not the result of running the code)? For example, how do I reference this block of code: ```{r blah} blah <- "blah" ``` I know that I can use \@ref(fig:theFig) or \@ref(tab:theTable) to get at fig.cap or caption (with kable) but I don't see a way to caption and reference the code itself. 回答1: This would be a great feature. And I think it is not integrated yet. Here is an approach that works for PDF documents and