In r-markdown is is an option to move the title:
out of the main yaml, as described in the R Markdown Cookbook.
But, in a xaringan slide set the new ---
seems to conflict with the idea of new slide.
The below code works, but when move line #2, title: "Presentation Ninja"
outside the main yaml, and inset it as title: "The name of the dog is
r dog_name!"
, by removing all my <!-- ... -->
code in line #17-19, it does not work as expected. I do no longer get a title page. I guess I need to work around the ---
in xaringan?
Any help would be appreciated!
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
output:
xaringan::moon_reader:
lib_dir: libs
---
# xaringan set the document title dynamically
```{r, code=xfun::read_utf8('script_with_many_dog_names.R')}
```
The name of the dog is `r dog_name`!
<!-- --- -->
<!-- title: "The name of the dog is `r dog_name`!" -->
<!-- --- -->
Some bullets
- Foo
- Bar
You could use R Markdown
parameters :
Template.Rmd
---
title: "The name of the dog is `r params$dog_name`"
subtitle: "⚔<br/>with xaringan"
author: "John Doe"
output:
xaringan::moon_reader:
lib_dir: libs
params:
dog_name: NA
---
# xaringan set the document title dynamically
Some bullets
- Foo
- Bar
dog_name
parameter :source('script_with_many_dog_names.R')
# As an example, but it could be the result of previous script
params <- list(dog_name = 'Charles')
rmarkdown::render('Template.Rmd', output_file = 'presentation.html',
params = params,
envir = new.env(parent = globalenv())
)
You can add your logic directly to the title, that seems to work fine for me:
---
title: "The number is `r round(100 * runif(1), 2)`"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
output:
xaringan::moon_reader:
lib_dir: libs
---
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With