Hey Shiny and Plumber experts,
Basically, we are trying to pass the output of shiny via Plumber to other programmers to integrate in an webpage.
From the documentation, running on local machine,
following works individually:
Plumber reprex
#* Plot a histogram
#* @png
#* @get /plot
function(){
random_num <- rnorm(10) * 5
hist(random_num)
}
saving the file as plumber.R
# Running the below in console
r <- plumb("plumber.R") # Where 'plumber.R' is the location of the file shown above
r$run(port=8000)
# Now, loading the browser: http://127.0.0.1:8000/__swagger__/

Similarly shiny reprex :
library(shiny)
# Define UI for application that plots random distributions
ui = shinyUI(fluidPage(
# Application title
titlePanel("Hello Shiny!"),
# Sidebar with a slider input for number of observations
sidebarLayout(
sidebarPanel(
sliderInput("obs",
"Number of observations:",
min = 1,
max = 1000,
value = 500)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
))
# Define server logic required to generate and plot a random distribution
server = shinyServer(function(input, output) {
# Expression that generates a plot of the distribution. The expression
# is wrapped in a call to renderPlot to indicate that:
#
# 1) It is "reactive" and therefore should be automatically
# re-executed when inputs change
# 2) Its output type is a plot
output$distPlot <- renderPlot({
# generate an rnorm distribution and plot it
dist <- rnorm(input$obs)
hist(dist)
})
})
# Run the app
shinyApp(ui, server)
How can we render shiny's output i.e histogram into plumber's swagger ?
i.e. How to display the user
Tried: Embedding the plumber function within Shiny's renderFunction
library(shiny)
# Define UI for application that plots random distributions
ui = shinyUI(fluidPage(
# Application title
titlePanel("Hello Shiny!"),
# Sidebar with a slider input for number of observations
sidebarLayout(
sidebarPanel(
sliderInput("obs",
"Number of observations:",
min = 1,
max = 1000,
value = 500)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
)
)
))
# Define server logic required to generate and plot a random distribution
server = shinyServer(function(input, output) {
# Expression that generates a plot of the distribution. The expression
# is wrapped in a call to renderPlot to indicate that:
#
# 1) It is "reactive" and therefore should be automatically
# re-executed when inputs change
# 2) Its output type is a plot
#### Embedding inside the shiny
output$distPlot <- renderPlot({
#* Plot a histogram
#* @png
#* @get /plot
function(){
# generate an rnorm distribution and plot it
dist <- rnorm(input$obs)
hist(dist)
}
})
})
shinyApp(ui, server)