r-markdown

Use rmarkdown/knitr to hold all code until the end

℡╲_俬逩灬. 提交于 2019-12-07 00:13:58
问题 I'd like to be able to generate a document using knitr/rmarkdown that keeps all the output together, but leaves the code until the end, ideally as a referenced footnote of sorts (i.e. the code for each figure or output can be looked up in the appendix using a footnote). Is this possible? 回答1: If I understand correctly what you mean. You can add a label to your original code chunk and then refer to it using a ref.label property and prevent its further execution with eval=FALSE . For instance:

knitr::kable is there a way to reduce the font size?

感情迁移 提交于 2019-12-06 23:21:14
问题 I am using this code chunk ```{r, echo = FALSE} knitr::kable(df) ``` However I would like to reduce the size of all font inside this table so that the output looks nicer. Is there a way to do that with kable or is there another package which supports it? 回答1: You can also try library(kableExtra) . It has a lot of options to customise the table. Specifically, for font size: https://haozhu233.github.io/kableExtra/awesome_table_in_html.html#font_size df %>% kable("html") %>% kable_styling(font

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:

How to get a second bibliography?

蓝咒 提交于 2019-12-06 20:10:13
问题 In rmarkdown PDF and HTML I want two bibliographies —one for papers/books, and one for software I have used in my research. I found this related issue but it doesn't answer my question since it's concerning the combination of two *.bib files into one bibliography. I'm used to place my bibliography with <div id="refs"></div> as explained here. Possibly a second one can be placed similarly with <div id="refs_2"></div> , but I couldn't figure out how to do it since this "refs" seems not to 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

NOTE or WARNING from package check when README.md includes images

我的未来我决定 提交于 2019-12-06 16:13:33
I have a package with a README.Rmd that I pass to rmarkdown::render() producing README.md and a directory README_files , which contains images in README.md . This looks like the tree below. README_files is not a standard package directory , so if it isn't in .Rbuildignore , checking the package with R CMD check shows a note: * checking top-level files ... NOTE Non-standard file/directory found at top level: README_files But including the directory in .Rbuildignore leads to a warning, if and only if checking the package --as-cran . IIUC Pandoc tries to generate HTML from README.md , but the