0

I would like to dynamically change the text of an R markdown report template I'm using depending on certain inputs. I'm calling knitr from the PowerShell.

This is the input I would like to insert into the R markdown text Input:

{
  "start": "1/21/2015",
  "end": "1/23/2015",
  "species: ["RBHS", "DBHS", "CBHS"]
}

.Rmd file

---
title: "Capture Report"
author: "Mitchell Gritts"
date: Sys.Date()
output: html_document
---

```{r load packages, include = FALSE}
LoadScripts()
```

## Capture Table

All SPECIESLIST captured between STARTDATE and ENDDATE are included 
in the table. Data included in the table are Species, NDOW ID, Sex, Age, 
Marks and Collar information.

SPECIESLIST, STARTDATE and ENDDATE are to be replaced with the values from the input.

Is there a way to do this with knitr or sweave. Or do I use search and replace functions to do this?

Mitch
  • 652
  • 1
  • 8
  • 14
  • Where is this json input and how do you want to call knitr? You could, e.g., have your Rmd document read the json from a file somewhere. Or if you've read the json object into your global environment, calling `knit` from the console (not from the RStudio button) you can reference global vars. Or you can use `brew` [as here](http://stackoverflow.com/a/14968164/903061). – Gregor Thomas Sep 15 '15 at 23:38
  • I've removed the JSON reference as what I meant was the input code box, and updated how I would like to call knitr. Brew is not an option as I must comply with IT rules. – Mitch Sep 16 '15 at 00:08
  • HAve you looked at brew? https://botthoughts.wordpress.com/ – Tyler Rinker Sep 16 '15 at 00:12
  • 3
    The [parametrized reports documentation](http://rmarkdown.rstudio.com/developer_parameterized_reports.html) at RStudio might be helpful. – eipi10 Sep 16 '15 at 00:34

0 Answers0