I can't able to generate PDF report, By default it saving as HTML even after changing the format in .Rmd. I have given the code below which I used, Kindly help me to solve this.
I'm quite new to markdown and R in general.
I am posting here because google searches did not yield any solution regarding this.
Thanks in advance!
Server.R
shinyServer(function(input, output) {
output$report = downloadHandler(
filename ='my_report.pdf',
content = function(file) {
tempReport <- file.path(tempdir(), "test.Rmd")
file.copy("test.Rmd", tempReport, overwrite = TRUE)
library(rmarkdown)
rmarkdown::render(tempReport, output_file = file,
params = input,
envir = new.env(parent = globalenv())
)
}
)
})
Ui.R
library(shiny)
shinyUI(basicPage(
downloadButton('report')
))
test.Rmd
---
title: "Dynamic report"
output: pdf_document
params:
n: NA
---
```{r}
# The `params` object is available in the document.
input$farmer_id