I am using knitr
, R markdown
, and a custom LaTeX
file to write a manuscript. The abstract is set as part of the YAML frontmatter. This works great, except that the results that I would like to include in the abstract are generated later in the document.
Having the abstract in the YAML makes some sense to me and I would prefer to keep it this way. Any thoughts on a way to have the abstract take advantage of calculations that happen later in the document?
A brief example:
---
title: 'How do I interpret R objects in YAML that are created in the document?'
author: Jeff Hollister
output:
pdf_document:
fig_caption: yes
keep_tex: yes
number_sections: yes
html_document: null
word_document: null
fontsize: 11pt
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
```