Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 闪亮:使用actionButton打开新的仪表板_R_Shiny_Shinydashboard_Action Button - Fatal编程技术网

R 闪亮:使用actionButton打开新的仪表板

R 闪亮:使用actionButton打开新的仪表板,r,shiny,shinydashboard,action-button,R,Shiny,Shinydashboard,Action Button,我想通过按下第一个仪表板上的操作按钮来打开第二个仪表板。我可以使用下面的代码来实现这一点,但仪表板是相互连接的。例如,如果我关闭第二个仪表板上的侧栏,第一个仪表板的侧栏也会关闭 这是服务器.R文件: function(input, output, session) { # some more code # react to clicking on button show2 observeEvent(input$show2, { # here is some more c

我想通过按下第一个仪表板上的操作按钮来打开第二个仪表板。我可以使用下面的代码来实现这一点,但仪表板是相互连接的。例如,如果我关闭第二个仪表板上的侧栏,第一个仪表板的侧栏也会关闭

这是服务器.R文件:

function(input, output, session) {
  # some more code

  # react to clicking on button show2
  observeEvent(input$show2, {
      # here is some more code
      showModal(settngsModal())
  })

  settngsModal <- function() {
    modalDialog(

      withTags({ 
        dashboardPage(
          dashboardHeader(
            title = "Second Dashboard"
          ),
          dashboardSidebar(
            sidebarMenu(
              menuItem("Widgets", tabName = "widgets", icon = icon("th"))
            )),
          dashboardBody(
            tabItem(tabName = "widgets",
                    h1("Widgets tab content")
            )
          )
        )
      }),
      title = "Settings",
      fade = TRUE)
  }
}
dashboardPage(

    dashboardHeader(
      title = "First dashboard"
    ),

    dashboardSidebar(collapsed = TRUE,sidebarMenu()),
    dashboardBody(),

      h1('Headline'),

      actionButton("show2", "Show second dashboard", size = 'lg')
    )
)
是否可以有一个“独立”的仪表板


甚至可能有两个可以并排使用的仪表板(因为现在第二个仪表板是一个弹出窗口,第一个仪表板只能在第二个仪表板关闭时使用)

您可以使用
shinyjs
在两个
仪表板页面
标记之间切换

下面是一个在两个仪表板之间切换的示例,有一个环绕呈现UI
Dashboard页面
元素
反应式


library(shiny)
library(shinydashboard)
library(shinyjs)

ui <-  tagList(
  useShinyjs(),

  div(id = "dashboard_two",
      style = "display:none",
      dashboardPage(
        dashboardHeader(
          title = "Second dashboard"
        ),
        dashboardSidebar(collapsed = TRUE,sidebarMenu()),
        dashboardBody(fluidRow(actionButton("show1", "Show first dashboard")),
                      fluidRow(box(title = "Dash Two", height = 300, "Testing Render")) )
      )
  ),

  div(id = "dashboard_one",
      style = "display:none",
      dashboardPage(

        dashboardHeader(
          title = "First dashboard"
        ),
        dashboardSidebar(collapsed = TRUE, sidebarMenu()),
        dashboardBody(actionButton("show2", "Show second dashboard")
                      )
      )
  )
)


server <- function(input, output) {
  shinyjs::show("dashboard_one")
  observeEvent({ input$show1; input$show2}, {
    shinyjs::toggle("dashboard_one")
    shinyjs::toggle("dashboard_two")
  })
}

shinyApp(ui, server)

图书馆(闪亮)
图书馆(shinydashboard)
图书馆(shinyjs)

ui它对我不起作用,我得到错误:找不到函数“标记列表”。如果它对你有用,你能告诉我如何解决这个问题吗?谢谢这很奇怪,你确定你正在加载上面所有的
库吗?这只是一个附带的
shinny
确保您编写了
tagList
而不是
tagList
:)是的,我甚至复制并粘贴了您的简单示例,并重新安装了Rtools和您使用的所有库。每次我得到:
警告:标记列表中的错误:找不到函数“标记列表”[没有可用的堆栈跟踪]
好的,完美。这是R文件的位置有问题。非常感谢你!