Как визуализировать вывод блеска через API-интерфейс водопроводчика / REST другим программистам? - PullRequest
0 голосов
/ 15 марта 2020

Эй, эксперты Shiny и Plumber,

Соответствующие ссылки: https://abndistro.com/post/2019/07/06/deploying-a-plumber-api-on-aws-ec2-instance/

https://abndistro.com/post/2019/07/06/deploying-a-shiny-app-with-shiny-server-on-an-aws-ec2-instance/

В основном, мы пытаемся передать результаты «блестящего» через Plumber другим программистам для интеграции в веб-страницу.

Из документации, работающей на локальном компьютере, индивидуально выполняются следующие операции:

Plumber92

#* 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__/ 
[![plumber output][1]][1]

Аналогично блестящему представлению:

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)

Как мы можем отобразить вывод блеска, то есть гистограмму, в чванство сантехника?

т.е. Как отобразить пользователя

Пробовал : Встраивание функции сантехника в 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)
...