我想知道是否有一种技巧可以将当前日期放在.rmd文档的YAML前端,由knitr和rmarkdown包处理。我曾经在我的维基页面顶部有这样一行字,
_baptiste, `r format(Sys.time(), "%d %B, %Y")`_
并且它将在html输出中转换为baptiste, 03 May, 2014。现在,我想利用rmarkdown提供的高级pandoc包装器,但在YAML头中有r代码似乎不起作用:
---
title: "Sample Document"
output:
html_document:
toc: true
theme: united
date: `r format(Sys.time(), "%d %B, %Y")`
author: baptiste
---
Error in yaml::yaml.load(front_matter) :
Scanner error: while scanning for the next token at line 6, column 7
found character that cannot start any token at line 6, column 7
Calls: <Anonymous> ... output_format_from_yaml_front_matter ->
parse_yaml_front_matter -> <Anonymous> -> .Call
有解决方案吗?