将一个数据透视表插入R闪亮的闪亮BS弹出窗口内

时间:2018-04-06 09:22:15

标签: shiny shinydashboard shinybs rpivottable

给定的R闪亮脚本基于单击显示文本的按钮创建popoup。

library(shiny)
library(shinyBS)
CR1_BS<-paste("i. This is line 1",
          "ii. This is line 2",
          "iii. This is line 3", sep = "<br>")
 ui <- fluidPage(
 actionButton("CR1_S1", "Button"),
 bsPopover(id="CR1_S1",title="x",content=CR1_BS ,"right",options = 
 list(container = "body")))

 server <- function(input, output){}
 shinyApp(ui, server)

我的要求是在点击按钮时在弹出窗口中放入下面的rpivotTable。

 library(rpivotTable)
 rpivotTable(mtcars,rows="gear",cols = c("cyl","carb"),width = "100%", 
 height = "400px")

1 个答案:

答案 0 :(得分:1)

这样的事情吗?

rm(list = ls())
library(shiny)
library(shinyBS)
library(rpivotTable)

shinyApp(
  ui =
    fluidPage(
      sidebarLayout(
        sidebarPanel(actionButton("CR1_S1", "Button")),
        mainPanel(
          bsModal("modalExample", "Your Table", "CR1_S1", size = "large",rpivotTableOutput("test"))
        )
      )
    ),
  server =
    function(input, output, session) {

      output$test <- rpivotTable::renderRpivotTable({
        rpivotTable(mtcars,rows="gear",cols = c("cyl","carb"),width = "100%", height = "400px")
      })
    }
)