Hi! I'm trying to make a reports from shiny app.
server.R:
hc <- reactive({
highchart() %>%
hc_chart(type = "line") %>%
hc_xAxis(cars$speed) %>%
hc_add_series(name = "dist", data = cars$speed)
})
params <- reactive({
list(
hc = hc()
)
})
output$report <- downloadHandler(
# For PDF output, change this to "report.pdf"
filename = "report3.pdf",
content = function(file) {
# Copy the report file to a temporary directory before processing it, in
# case we don't have write permissions to the current working dir (which
# can happen when deployed).
tempReport <- "rmd/report3.Rmd"
file.copy("report3.Rmd", tempReport, overwrite = TRUE)
# Set up parameters to pass to Rmd document
params <- params()
# Knit the document, passing in the `params` list, and eval it in a
# child of the global environment (this isolates the code in the document
# from the code in this app).
rmarkdown::render(tempReport, output_file = file, runtime = "auto",
params = params,
envir = new.env(parent = globalenv())
)
}
)
report3.Rmd:
---
title: "Dynamic report"
output: pdf_document
params:
n: NA
hc: NA
---
```{r}
params$hc
I do not get the picture correctly. Can you please help?