Questions tagged [r-markdown]

R Flavored Markdown or "R Markdown" is a markdown variant used for content-creation and/or programming documentation interleaved with R code.

R Flavored Markdown, or simply "R Markdown", is a markdown variant used for content-creation and/or programming documentation in which text content is interleaved with R code. It is a modern example of literate programming and is frequently used in R vignettes and README files where an R Markdown file (usually with file extension .Rmd) is rendered as HTML via knitr pre-processing of embedded code chunks.

More details about R Markdown can be found in:

Two R packages currently implement R Markdown rendering:

Various script editors can display R Markdown documents with syntax highlighting and render the resulting markdown and HTML documents, including:

  • RStudio, a popular R IDE
  • Rcmdr, a graphical user interface available as an R package
10493 questions
67
votes
3 answers

R markdown: Accessing variable from code chunk (variable scope)

In R markdown (knitr package), can I access a variable within the body of the document that was calculated in a code chunk?
m.templemire
  • 725
  • 1
  • 6
  • 8
66
votes
7 answers

two-column layouts in RStudio presentations/slidify/pandoc

I'm trying to come up with a good system for generating slides and accompanying handouts. The ideal system would have the following properties: beautiful in both presentation (PDF/HTML) and handout (PDF) layouts (handouts should have room for…
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
65
votes
2 answers

R markdown link is not formatted blue when knitted to pdf

for some reason no link in my R markdowns (rmd) is formatted blue. knitting the simple rmd below to pdf is leaving the text color black. only when hovering over it does one realize that it's actually a link. knitting it to html will make the link…
Triamus
  • 2,415
  • 5
  • 27
  • 37
65
votes
1 answer

preventing a chunk run in rmarkdown

I am using Rmarkdown and Knitr using Rstudio. The following both print script and output to html. ```{r} summary(cars) ``` However the following will only print the output, that is embedded plot. ```{r, echo=FALSE} plot(cars) ``` I have…
SHRram
  • 4,127
  • 7
  • 35
  • 53
64
votes
4 answers

How can I force a line break in rmarkdown's title?

I have a quite long title in a rmarkdown document and I would like to force a line break in a specific position. Minimum example: --- title: "Quite long title want the * line break at the asterisk" output: html_document --- I have tried: \n,…
Jon Nagra
  • 1,538
  • 1
  • 16
  • 36
62
votes
5 answers

How to export RMarkdown file to HTML document with two columns?

I am putting together an R Markdown HTML page for some new R users at my work to give them an introduction and walk them through some simple demos. While showing off things like head and tail, it ends up looking messy and long because it prints out…
bryanR
  • 721
  • 1
  • 6
  • 6
61
votes
1 answer

Automatically number sections in RMarkdown

I am trying to create a report in R markdown that has sections ordered Section 1 Header 1.1 sub section 1 1.2 sub section 3 Section 2 Header 2.1 2.2 sub section 2.2.1 another sub section Is there a way get R markdown to generate an ordered…
H.Bananas
  • 711
  • 1
  • 6
  • 5
60
votes
3 answers

Setting document title in Rmarkdown from parameters

I've got an Rmarkdown template that works well, and I've parameterized it so I can generate variants of the same report from different data sources. However, I'd like to change the title of the report in each case. How do I do that? Here's the YAML…
Harlan
  • 18,883
  • 8
  • 47
  • 56
60
votes
5 answers

Code chunk font size in Rmarkdown with knitr and latex

In knitr, the size option works fine in a .Rnw file, the following code generates: \documentclass{article} \begin{document} <>= summary(mtcars) @ \end{document} However, I can't get it to work in Rmarkdown. The following…
Carlos Cinelli
  • 11,354
  • 9
  • 43
  • 66
59
votes
4 answers

Producing subscripts in R markdown

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.
sebastian-c
  • 15,057
  • 3
  • 47
  • 93
58
votes
2 answers

How to send R markdown report in body of email?

update: Brandon Bertelsen's answer: Brandon's answer produces the following output. It doesn't produce nice tables or highlight code like Rstudio does, and it crashes on some html files with unicode, so I'm not using it to automate my email…
Nelson Auner
  • 1,421
  • 1
  • 15
  • 21
58
votes
3 answers

How can I use Emacs ESS mode with R markdown?

Is there a way to configure Emacs so that it recognizes (and allows execution of) R code chunks within R markdown (.Rmd) files similar to the way it recognizes code chunks in .Rnw (Sweave) or .org (org-mode) files?
David LeBauer
  • 31,011
  • 31
  • 115
  • 189
57
votes
4 answers

R Markdown - variable output name

With one R markdown file, I would like to create different possible output pdf documents, where the output file name should be defined within the document. Is there any way to convince markdown to manipulate the output filename in such a way?…
Sosel
  • 1,678
  • 1
  • 16
  • 31
57
votes
5 answers

How to add whitespace to an RMarkdown document?

Is there a way to do it by adding latex code in the text or does the solution lie in (R)Markdown? No sign of a solution here: http://rmarkdown.rstudio.com/pdf_document_format.html At present I'm bodging a solution by adding my monospace signature to…
RobinLovelace
  • 4,799
  • 6
  • 29
  • 40
55
votes
5 answers

How do I add a URL to R markdown?

I want to refer a URL link to the R markdown and I already tried the input such as "addlink" or "address <- ...." Both of them do not work. How can I add a link in R markdown? Thanks! EDIT: op's code from comment was {r} [linked phrase]…
Jennifer Liu
  • 571
  • 1
  • 5
  • 6