knitr

how do you color the cell in rmarkdown pdf output

会有一股神秘感。 提交于 2019-12-06 22:18:57
问题 I cannot get cellcolor to work in rmarkdown: --- header-includes: - \usepackage{colortbl} - \usepackage{color} output: pdf_document --- ```{r, results="asis"} library(xtable) # Your data tab = data.frame(category = c("A","B","C"), groupA = c(.2,.3,.5), groupB= c(.6,.7,.9)) # Function to cut your data, and assign colour to each range f <- function(x) cut(x, c(0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, Inf), labels=c("green", "red", "blue", "orange", "yellow", "purple", "brown", "white"), include

Can't change params in Rmd documents

血红的双手。 提交于 2019-12-06 22:11:39
问题 As explained on this site it is possible to define parameters in the YAML header of a Rmarkdown file and the default values specified there can be overwritten with rmarkdown::render("foo.Rmd", params = list(param1 = "bar") . However when I try this I get the following error: params object already exists in knit environment so can't be overwritten by render params Here is a minimal reproducible Rmd document. Let's say the file name is test.Rmd . --- title: "Test" output: pdf_document params:

Can I use a knitr inline expression in the title of a latex document?

廉价感情. 提交于 2019-12-06 20:55:35
问题 I'd like to use a Knitr/Sweave in-line call ( \Sexpr{} ) in the title of a LaTeX document, after the \begin{document} command but before the \maketitle command. The in-line R code would extract one or two pieces of information from an R data-frame created early in the R script I'm embedding in LaTeX. I have a couple of Knitr chunks that create a data.frame from which I derive the information I want to put in the Title. I've tried placing these chunks between LaTeX's \begin{document} call and

RStudio, knitr, pandoc, Word: how do I get a 'new page' in my docx?

廉价感情. 提交于 2019-12-06 20:37:27
问题 I am using the RStudio, knitr, pandoc, MS Word combo to get my final results in a docx document. Occasionally, I would like the report to continue on a new page. I can't find the way to achieve this. From what I have Googled, it seems to be possible with CSS . I don't know HTML or CSS , but if it is the solution I will learn. Just don't want to take the wrong road... 回答1: Try the LaTeX command \newpage. Pandoc recognizes it and might (not on a computer right now) translate it to a Word page

Produce two plots from same chunk / statement in knitr

China☆狼群 提交于 2019-12-06 19:53:12
问题 Is it possible to have plot-generating code output two versions of the same figure, at different sizes, from a .Rmd document? Either through chunk options (I didn't see anything that works directly here), or through a custom knitr hook? Preferably this would be done with the png device. My motivation: I'd like to be able to output a figure at one size, which would fit inline in a compiled HTML document, and another figure that a user could show after clicking (think fancybox). I think I'll be

multi-line equation in RMarkdown

橙三吉。 提交于 2019-12-06 19:43:41
问题 I am trying to create a multi-line equation in RMarkdown. I have tried the following code, extracted from http://www.rstudio.com/ide/docs/authoring/using_markdown_equations, $$ \begin{aligned} \dot{x} & = \sigma(y-x) \\ \dot{y} & = \rho x- y - xz \end{aligned} $$ however the knitred HTML document gives a single-line equation: 回答1: This code produced 2 HTML lines, as desired, when cut and paste into RStudio in Windows 7 with knitr. If the second slash at the end of the 3rd line was removed, it

Programmatically insert header and plot in same code chunk with R markdown using results='asis'

人走茶凉 提交于 2019-12-06 19:37:38
问题 The results = 'asis' chunk option within Rmarkdown allows one to easily dynamically create text including headers. However, I wish to dynamically create a header with the asis option, but then in the same code chunk insert some graphics. The most related answer I could find for this is here: Programmatically insert text, headers and lists with R markdown, but the answer to this question does not allow both dynamic headers and plots within those dynamic headers. Here is a simple reproducible

Executing Perl 6 code in Rmarkdown

試著忘記壹切 提交于 2019-12-06 19:37:17
问题 I want to write some tutorials on Perl 6. For this I believe Rmarkdown would be of great help. So I am trying to execute Perl 6 code within Rmarkdown document. My Perl 6 executable is in C:\rakudo\bin . So my .Rmd file with example code to accomplish this is as follow: --- title: "Example" output: html_document --- ```{r, engine='perl6', engine.path='C:\\rakudo\\bin'} my $s= "knitr is really good"; say $s; ``` However knitting the above document in Rstudio shows the following without Perl 6

How to make scrollable slides in an ioslides presentation with rmarkdown

大兔子大兔子 提交于 2019-12-06 19:01:03
问题 I am using RMarkdown to create an ioslide presentation with shiny. Some of my slides do not actually fit on one page and are truncated. Since this is a HTML output, I would like to add a scroll bar to make my long slides scrollable. I have been googling a lot and found a partial solution to make R code chunks scrollable. However I want to make my slides scrollable regardless of the content. This is a toy Rmd example giving slides not fitting on one page: --- title: "Untitled" date: "30

Cache SQL chunk with R Markdown / Notebook without Knitting in RStudio

旧街凉风 提交于 2019-12-06 14:07:17
I have a chunk of SQL in my R Markdown / Notebook Document: ```{sql output.var = "df"} SELECT * FROM FakeData WHERE Date >= '2017-01-01 ``` It takes literally 5 minutes to run. Is there an easy way to cache the result of the query without Knitting the document or writing the file to a CSV. I'd perhaps like the cache to live for a couple of hours, or maybe a day (is there a way to adjust this as well?) If you put cache=TRUE in the chunk options and you are working in rStudio, you can select a section of code and run it directly using the green arrows in the upper right of the rMarkdown/knitr