小编Ala*_*Lin的帖子

如何在 Shiny App 中使用 URL 渲染 HTML 文件而不破坏其他交互式图表和表格?

我制作了一个闪亮的应用程序,它连接到远程数据库(PostgreSQL)来提取表格,以便在我的应用程序中显示,并使用表格中的值生成用户交互式图(箱线图、散点图、直方图)。

该应用程序的另一部分是在应用程序中呈现托管在网站(例如 GitHub)上的 HTML 文件。

这是我使用的代码的一部分:

    output$genotyping <- renderUI({
      if (creds_reactive()$user == "Admin") {
        
      fluidPage(useShinyjs(),
                titlePanel("Github HTML file"),
                mainPanel(
                  
                  h3("Click this button to display/hide the html file"),
                  br(),
                  br(),
                  actionButton("genotype", "Click me!"),
                  hidden(
                    div(id = 'text_div',
                  htmlOutput("includeHTML")
                  ) )
                )
                
      ) }
      else {
        mainPanel(
          fluidRow(
            align = "center", 
            h3("Sorry! You don't have the permissions required to view this content.")
          )
        )
        
      }
    })
            
    request <- GET("link to html file")
    github.html <-content(request, as ="text")  
    
    observeEvent(input$genotype, {
            
        toggle('text_div')
        output$includeHTML <- renderText({github.html}) …
Run Code Online (Sandbox Code Playgroud)

html r shiny

5
推荐指数
1
解决办法
551
查看次数

标签 统计

html ×1

r ×1

shiny ×1