代码之家  ›  专栏  ›  技术社区  ›  antecessor

在bsplus函数中集成r输出

  •  1
  • antecessor  · 技术社区  · 7 年前

    我认为 bsplus 在开发动态Web时打包为相关的。我在rstudio中使用r markdown。

    但是,我发现整合的方法特别复杂 巴斯普勒斯 具有R输出的函数。

    我们来看一个例子 bs_accordion 函数,使用 mtcars 数据集

    head <- head(mtcars)
    tail <- tail(mtcars)
    
    bs_accordion(id ="Data: mtcars") %>%
      bs_append(title = "Head of mtcars", content = head) %>%
      bs_append(title = "Tail of mtcars", content = tail)
    

    我想在Accordion函数中显示R输出,显示数据帧 head tail .

    现在,它只显示 .

    是否有可能在 content 属性 巴斯普勒斯 功能?

    这样我们就可以动态地显示R结果。

    1 回复  |  直到 7 年前
        1
  •  1
  •   SeGa    7 年前

    这对于您的示例应该有效。您必须以某种方式创建一个数据表,只是包含它不会将其呈现为表。

    注意:我把手风琴的ID改成了 Data-mtcars . 使用空格“:”或“;”将禁用折叠。

    library(shiny)
    library(bsplus)
    library(DT)
    
    ui <- fluidPage(
      bs_accordion(id ="Data-mtcars") %>%
        bs_set_opts(panel_type = "primary", use_heading_link = T) %>%
        bs_append(title = "Head of mtcars", content = DT::dataTableOutput("table1")) %>%
    
        bs_set_opts(panel_type = "primary", use_heading_link = T) %>%
        bs_append(title = "Tail of mtcars", content = DT::dataTableOutput("table2"))
    )
    
    server <- function(input, output) {
    
      output$table1 <- DT::renderDataTable({
        head
      })  
      output$table2 <- DT::renderDataTable({
        tail
      })
    }
    
    shinyApp(ui, server)
    
    推荐文章