I like to put the R-code that produced a shiny thing (graph, table, whatever) below the thing itself. It's annoying however to maintain 2 bits of code that are essentially the same. Is there any way to...capture (?) some R code, or something where I could get a text output for the shiny app. As an example:
output$graphGroup <- renderPlot({
shinyAce::updateAceEditor(session,
value = boxPlots_code(),
editorId = "boxCode_out" )
boxPlots_create()
})
boxPlots_create <- reactive({
thing1 <- as.numeric(input$thing1)
thing2 <- as.logical(input$thing2)
boxPlot <- plot_function(x,
thing1, thing2)
return(bioPlot)
})
boxPlots_code <- reactive({
thing1 <- as.numeric(input$thing1)
thing2 <- as.logical(input$thing2)
boxPlotCode <- paste0(rCodeSetup(),'
boxPlot <- plot_function(x,
', thing1,", ", thing2,")")
return(boxPlotCode)
})
Ideally I'd like to take the "boxPlots_create" code and turn it into a single character. I've started messing with the "formals" function, and looking a bit at roxygen (because it kind of does a that type of stuff). Another option would be to make a source file for each chunk of shiny code, and either source that file, or grab the text. But, I wanted to check here first to see if I'm just missing some awesome R-function (be it base or some package I need to check out).