Skip to content

Instantly share code, notes, and snippets.

@jhollist
Created September 12, 2014 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhollist/2d817b30ccd570e8e184 to your computer and use it in GitHub Desktop.
Save jhollist/2d817b30ccd570e8e184 to your computer and use it in GitHub Desktop.
Example of .Rmd, with YAML trying to interpret code and objects set later in document
---
title: 'How do I interpret R code in YAML?'
author: Jeff Hollister
output:
pdf_document:
fig_caption: yes
keep_tex: yes
number_sections: yes
html_document: null
word_document: null
fontsize: 11pt
capsize: normalsize
csl: components/ecology.csl
documentclass: article
abstract: This is a test. Is this `r mean(x)` working?
---
This is a test of outputing a pdf, with R code interpretted in the YAML front mater. Use case for this would be a manuscript, with abstract as part of YAML, and some of the results in the abstract being calculated in the body of the Rmd. For instance:
```{r}
x<-rnorm(100)
mn<-mean(x)
mn
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment