Split shiny app into two columns, show all code in app.R in right hand column

I would like to show the code used in a shiny app within the app itself.

Perfect example: Shiny - Generating reports

On that link there is another link 'Get Code'. If I click through to that link and run the code in app.R (below) it shows what's in the left column only, the shiny app.

Is there a way to also show the actual code in the right hand column like on the first link above?

shinyApp(
  ui = fluidPage(
    sliderInput("slider", "Slider", 1, 100, 50),
    downloadButton("report", "Generate report")
  ),
  server = function(input, output) {
    output$report <- downloadHandler(
      # For PDF output, change this to "report.pdf"
      filename = "report.html",
      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 <- file.path(tempdir(), "report.Rmd")
        file.copy("report.Rmd", tempReport, overwrite = TRUE)

        # Set up parameters to pass to Rmd document
        params <- list(n = input$slider)

        # 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,
          params = params,
          envir = new.env(parent = globalenv())
        )
      }
    )
  }
)

I'd like to show what's in the light grey border 'app.R' in this screen shot:

How can I do that?

If I understand you correctly, you're referring to the showcase mode?

You can get the effect using display.mode = "showcase" as shown here.

runApp("MyApp", display.mode = "showcase")

More info here:

I hope that I'm understanding you correctly and this is actually of help :stuck_out_tongue:

1 Like

Yes! This is exactly what I was looking for. Thank you.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.