profvis_ui {profvis} | R Documentation |
Profvis UI for Shiny Apps
Description
Use this Shiny module to inject Profvis controls into your Shiny app. The Profvis Shiny module injects UI that can be used to start and stop profiling, and either view the results in the Profvis UI or download the raw .Rprof data. It is highly recommended that this be used for testing and debugging only, and not included in production apps!
Usage
profvis_ui(id)
profvis_server(input, output, session, dir = ".")
Arguments
id |
Output id from |
input , output , session |
Arguments provided by
|
dir |
Output directory to save Rprof files. |
Details
The usual way to use Profvis with Shiny is to simply call 'profvis(shiny::runApp())', but this may not always be possible or desirable: first, if you only want to profile a particular interaction in the Shiny app and not capture all the calculations involved in starting up the app and getting it into the correct state; and second, if you're trying to profile an application that's been deployed to a server.
For more details on how to invoke Shiny modules, see [this article](https://shiny.rstudio.com/articles/modules.html).
Examples
# In order to avoid "Hit <Return> to see next plot" prompts,
# run this example with `example(profvis_ui, ask=FALSE)`
if(interactive()) {
library(shiny)
library(ggplot2)
shinyApp(
fluidPage(
plotOutput("plot"),
actionButton("new", "New plot"),
profvis_ui("profiler")
),
function(input, output, session) {
callModule(profvis_server, "profiler")
output$plot <- renderPlot({
input$new
ggplot(diamonds, aes(carat, price)) + geom_point()
})
}
)
}