Could some one point me to an example of how to generate a markdown document based on inputs in Shiny? Ideally, I would render the markdown document in the application, rather than downloading it.
This example is pretty close to what I am looking for, but I don't know what the contents of the report.Rmd' file or how to pass parameters to it, courtesy of this Stackoverflow question
There is a good Rstudio reference guide. I would read the Passing Parameters section carefully.
Essentially you set up your Rmd document with the parameters defined in the header, then you use rmarkdown::render() to pass along a list of parameters to be used in the report.
To use the shiny inputs as parameters you'd need to isolate the input object as you pass it into rmarkdown::render() as an option to params. e.g.
Is it possible to produce multiple reports (let's say, a report per region) when a user clicks on the button? If so, how would that work? I envision utilizing the purrr::walk() function to make this happen, but I'm not sure I'm applying it correctly.
Also, is there a possibility of zipping the multiple documents produced and have the user download a single .zip file instead of multiple files?
Yes, if we use the article @barbara shared with you as the base, then you would use purrr::walk to run the rmarkdown::render() function, and add the region to the params list.
I have not tested this code, but it would look something like this:
I'm looking for the production of multiple reports, one per region.
I have a project in which the client has about 250 branch locations, and they would like the ability for their branch managers to receive a PDF report for their own branch location. We've mentioned to them the possibility of providing user login access to the app for each manager that would be restricted to their branch, but they didn't appear interested in that aspect.
The current set-up is that a user can select a particular branch and then download that branch's report, but needless to say it's quite manually-intensive due to the sheer number of branches.
I do have another issue - which I'm not sure can be replicated.
I have put together below a more simplified version of the initial app. For some reason, when I click on "Generate report", the file created is called "report" when I specified it to be "report.pdf". I end up having to manually change the downloaded file name to add ".pdf" in order for my computer to recognize it as a PDF document. Is anyone else experiencing the same issue? Is there a correction to be made to the below?
---
title: "Dynamic report"
output: pdf_document
params:
n: NA
---
```{r}
# The `params` object is available in the document.
params$n
```
A plot of `r params$n` random points.
```{r}
plot(rnorm(params$n), rnorm(params$n))
```