knitr

Combining R Markdown and Animation Package

一个人想着一个人 提交于 2019-12-18 16:42:12
问题 Is there a way to combine animation package and r markdown? I want to generate animation which i want to include and describe in html file generated from r markdown. Of course I can embed code from saveHTML or saveGIF file in already generated r markdown file, but i want to automate this process. I'm working on Windows, R 15.1 and the last RStudio. 回答1: Here is the clock example from the knitr graphics manual (see comment on your question) in markdown: ```{r clock, fig.width=7, fig.height=6,

Combining R Markdown and Animation Package

我怕爱的太早我们不能终老 提交于 2019-12-18 16:41:52
问题 Is there a way to combine animation package and r markdown? I want to generate animation which i want to include and describe in html file generated from r markdown. Of course I can embed code from saveHTML or saveGIF file in already generated r markdown file, but i want to automate this process. I'm working on Windows, R 15.1 and the last RStudio. 回答1: Here is the clock example from the knitr graphics manual (see comment on your question) in markdown: ```{r clock, fig.width=7, fig.height=6,

Captions on tables in pdf documents generated by rmarkdown

a 夏天 提交于 2019-12-18 16:25:11
问题 How can I get captions on my table floats in pdf_document generated by rmarkdown? Using output: pdf_document: fig_caption: true and ```{r, fig.cap='a caption'} myplot ``` Generates a floating figure with myplot and the caption specified. How do I achieve the same thing with tables generated by xtable? ```{r, results='asis', fig.cap='table caption'} print(xtable(table), comment = FALSE) ``` I have tried using floating.environment = 'figure' in print.xtable, but to no avail. 回答1: Or similarly,

How to set the number of decimals in report produced with knitr/pander?

情到浓时终转凉″ 提交于 2019-12-18 15:47:15
问题 I know it's a fairly old problem, and it has been discussed before, but I can't get it work as expected. I have a markdown document, and I would like to use knitr and pander to produce a .docx report with a consistent numeric format with two decimals, such as 0.12, 3.60, 14.00, or 163.21 for both inline and chunk outputs. I have read this thread How to avoid using round() in every \Sexpr{}? where it was suggested that pander can do that automatically. However, it does not seem to work for me.

Changing the Color of negative numbers to Red in a table generated with xtable()?

时间秒杀一切 提交于 2019-12-18 12:53:16
问题 I'm writing a report in R with knitr. I'm using xtable() to generate tables in the report. One of my tables includes both negative and positive numbers. I'd like to change the color of negative numbers into red. How can I do that? Obviously, one easy solution is to change the latex code that xtable generates BUT note that I have an auto-report that numbers can change with new datasets and I don't want to manually set the colors. Here is a simple code: \documentclass{article} \begin{document}

How can we pass pandoc_args to yaml header in rmarkdown?

允我心安 提交于 2019-12-18 12:29:19
问题 I'm using rmarkdown to produce a word (.docx) report. I would like to change the header of the toc. This seems possible as pandoc_args can be passed as options in the yaml header in the case of a doc file (1). But I'm not doing it right. Could anyone provide a working example ? (1) pandoc.args is included in the rmarkdown possible options and in the pandoc manual, there is a toc-title option --- title: "yaml header" author: "cedric" output: word_document: toc: true pandoc_args: toc-title=

Adding custom CSS tags to an RMarkdown html document

与世无争的帅哥 提交于 2019-12-18 12:15:40
问题 I have an RMarkdown document outputting to HTML of the same form as the below example. What do I add where to apply unique CSS ids or classes to each plot output? --- title: "RMarkdown" author: "Me" date: "Friday, March 27, 2015" output: html_document: theme: null css: style.css --- ```{r plot1, echo=FALSE, warning=FALSE, message=FALSE} library(ggplot2) x <- ggplot(some_r_code) print(x) ``` ```{r plot2, echo=FALSE, warning=FALSE, message=FALSE} y <- ggplot(some_more_r_code) print(y) ``` I've

R markdown: Accessing variable from code chunk (variable scope) [duplicate]

岁酱吖の 提交于 2019-12-18 11:15:23
问题 This question already has answers here : Is there an R Markdown equivalent to \Sexpr{} in Sweave? (2 answers) Closed last year . In R markdown (knitr package), can I access a variable within the body of the document that was calculated in a code chunk? 回答1: Yes. You can simply call any previously evaluated variable inline. e.g. If you had previously created a data.frame in a chunk with df <- data.frame(x=1:10) `r max(df$x)` Should produce 10 回答2: I would like to add that this is not the case

Side by side Xtables in Rmarkdown

浪子不回头ぞ 提交于 2019-12-18 11:09:59
问题 I have seen answers to creating side by side xtables in RMarkdown-HTML knitr, R Markdown, and xtable: xtable tables within HTML table and how to create side by side xtables in Sweave directly R: Print two tables with xtable () But how about side by side xtables in Rmarkdown/Pandoc? In my *Rmd file I have ```{r , results='asis', message=FALSE, echo=FALSE} female.bmi <- lm(bmi ~ AGEGROUP + RACE + GEO_SPA + FPL_FIN + as.factor(year), data=lach[lach$GENDER=='Female',] ) xtable(female.bmi, comment

Producing subscripts in R markdown

╄→гoц情女王★ 提交于 2019-12-18 10:46:09
问题 I'm aware that R markdown can produce superscripts: text^superscript But is it possible to produce proper subscripts? Or is the only way to do so to cheat and use LaTeX math mode: $\sf{text_{subscript}}$ The intended final output is HTML. 回答1: Since you mention Pandoc in your comments, maybe it's not cheating to depend on Pandoc's extensions for subscript and superscript . From here, we can create a minimal example Rmd file: Testing Subscript and Superscript ==================================