Knitr YAML on the fly: brew 'pre processing' - lmmx/devnotes GitHub Wiki
As described in issue 455 of the knitr package, a preprocessor hook was misguided, rather it's suggested to write YAML headers programmatically via the brew package and temporary intermediate .Rmd files.
Inline R can be given in headers only where unevaluated text is appropriate: for example the date: and title: fields.
Ramnath provides an example of such YAML headers in this SO answer