Capture arguments inside functions in server.R

Hi all,

Below is sample of the server.R file from R shiny application. So wanted to check if we can show that output$plot is a function that has input$dist , dist , n , input$n , hist inside this function. Is this possible to achieve?

output$plot <- renderPlot({
    dist <- input$dist
    n <- input$n

    hist(d(),
         main = paste("r", dist, "(", n, ")", sep = ""),
         col = "#75AADB", border = "white")
  })

You could use shinymeta to expose the full code of the renderPlot.

Thsnks. Can you show a sample please if you do not mind

Thanks for the comment. But It solved but not completely. For example, I added extra lines of code below to the application that was there in Read.me. So it does not show what function is there inside output$fun . Makes sense?

library(shiny)
library(shinymeta)

asd <- function(a,b){
  c <- a + b
  return(c)
}


ui <- fluidPage(
  selectInput("var", label = "Choose a variable", choices = names(cars)),
  verbatimTextOutput("Summary"),
  verbatimTextOutput("code"),
  verbatimTextOutput("fun") # extra
)

server <- function(input, output) {
  var <- metaReactive({
    cars[[..(input$var)]]
  })
  output$Summary <- metaRender(renderPrint, {
    summary(..(var()))
  })
  output$code <- renderPrint({
    expandChain(output$Summary())
  })

# extra
  output$fun <- renderPrint({
    expandChain(asd(3,4))
  })
}

shinyApp(ui, server)

Also Nir, Say, we have already application that is been built. And it has many funtions like I showed in my question. Below if for your reference

output$plot <- renderPlot({
    dist <- input$dist
    n <- input$n

    hist(d(),
         main = paste("r", dist, "(", n, ")", sep = ""),
         col = "#75AADB", border = "white")
  })

In that case it will be very difficult to reframe the entire application based on shinymeta. So is there not a way to capture the arguments for the above function separately

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