user1638567
user1638567

Reputation: 79

markdown and bookdown -run by factors

I am brand new to markdown language.

I am using bookdown to generate reports. I have two questions:

If I have one stacked dataset with one column being a factor...

  1. Is it possible to run separate reports by each factor level (note: I know how to do this analysis in R, I want to know if I can export separate results by each factor as separate reports. Any tips to do this are appreciated.

  2. Can you reference this level in the TEXT section of the report?

I want one report titled, "Results for A" with stats=1234 and another report titled "Results for B with stats=567" where A and B are the levels of a factor.

Does that make sense? All help is appreciated. I want one report titled, "Results for A" with mode = 2 and another report titled "Results for B with mode = 3".

Does that make sense? All help is appreciated.

Upvotes: 0

Views: 48

Answers (1)

nobits
nobits

Reputation: 66

You can pass a parameter to the report. The parameter has to be defined in the yaml header Example:

in example.rmd:

---
output: html_document
params:
  stats: NA # default value
---
Results for stats = `r params$stats`

And pass the parameter as such:

rmarkdown::render("example.rmd", params = list(stats = 123))

Upvotes: 1

Related Questions