在闪亮中动态渲染长方体 [英] Render Box Dynamically in Shiny

查看:0
本文介绍了在闪亮中动态渲染长方体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何根据数据将长方体渲染为有光泽。 数据是由用户上传的,它可以有更多的数据,所以我必须创建 一个动态的盒子。 我正在运行下面的代码,我得到了四个框创建在控制台,而不是在闪亮的网页。 请看一下,谢谢。

代码

   list_data <- list(c("AB","CD","EF","GH"))  #data

ui <- dashboardPage(
      dashboardHeader(title = "Text Mining"),
        dashboardSidebar(
         sidebarMenu(
          menuItem("NLP Tree", tabName = "NLP")
         )
       ),

      dashboardBody(
       tabItems(
        tabItem(tabName = "NLP",
         fluidRow(
          tabBox(width = 12,height="500",
           tabPanel("Sentences",
            uiOutput("nlp_sentences_tree")
                   )
            ) 
           )  
          )
         )   
        )
       )



server <- function(input, output) {

  output$nlp_sentences_tree <- renderUI({

    for(i in list_data[[1]]){
     print(box(width = 8,
            i
           )
         )
        }
     }) 
    }

  shinyApp(ui = ui, server = server)

推荐答案

看看这里,我为每个按钮都添加了一个按钮,这样里面就有东西了

library(shinydashboard)
library(shiny)

list_data <- list(c("AB","CD","EF","GH"))  #data

ui <- dashboardPage(
  dashboardHeader(title = "Text Mining"),
  dashboardSidebar(
    sidebarMenu(
      menuItem("NLP Tree", tabName = "NLP")
    )
  ),

  dashboardBody(
    tabItems(
      tabItem(tabName = "NLP",
              fluidRow(
                tabBox(width = 12,height="500",
                       tabPanel("Sentences",
                                uiOutput("nlp_sentences_tree")
                       )
                ) 
              )  
      )
    )   
  )
)



server <- function(input, output) {

  v <- list()
  for (i in 1:length(list_data[[1]])){
    v[[i]] <- box(width = 8, list_data[[1]][i],actionButton(i,i))
  }
  output$nlp_sentences_tree <- renderUI(v)
}

shinyApp(ui = ui, server = server)

这篇关于在闪亮中动态渲染长方体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆