Skip to content

How to pass tables and plots from different modules in Shiny app as parameters to R Markdown? #971

Answered by YonghuiDong
YonghuiDong asked this question in Q&A
Discussion options

You must be logged in to vote

I figured out the solution:

  1. Export the output in the module
  2. Pass them in the download module server file
  3. Include in the download module server file in the general server file

Here is a mini example.

library(shiny)
library(ggplot2)
library(rmarkdown)
# Module 1,
plot_ui <- function(id) {
  ns <- NS(id)
  tagList(
    plotOutput(ns("plot1")),
    plotOutput(ns("plot2"))
  )
}

plot_server <- function(id) {
  moduleServer(id, function(input, output, session) {
    myplot1 <- reactive({
      ggplot(mtcars, aes(wt, mpg)) +
        geom_point()
    })
    myplot2 <- reactive({
      ggplot(mtcars, aes(wt, drat)) +
        geom_point()
    })
    output$plot1 <-renderPlot({
      myplot1()
…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by YonghuiDong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant