我将两个数据框放在一个选项卡面板中,出现在仪表板Body上. 有人能帮我把这个选项卡板连接到仪表板边栏上显示的标题为"Inventory"的menuSubItem上吗?

此外,我需要一个帮助来创建两个数据框之间的空间,因为他们位于一个单一的选项卡面板一个在另一个.

df1 = data.table(
    "Сolumn1"= as.character(),
    "Column2"= as.numeric())

df2 = data.table(
    "Сolumn1"= as.character(),
    "Column2"= as.numeric())


ui <- dashboardPage(
  dashboardHeader(title = "Assets"),
  dashboardSidebar(
    menuItem("Home", tabName = "home"),
    menuItem("Current assets", tabName = "CurrentAssets",
    menuSubItem("Inventory", tabName="inventory")
   )
  ),
  dashboardBody(
    tabsetPanel(
      tabPanel(tabName = "inventory",
        "df1",
        rHandsontableOutput("Table1")
        ),
    tabsetPanel(
      tabPanel(tabName = "inventory",
        "df2",
        rHandsontableOutput("Table2")
    )
      )
    )
  )
)


server <- function(input, output, session) {

    output$Table1 <- renderRHandsontable({
            rhandsontable(df1)
  })

    output$Table2 <- renderRHandsontable({
            rhandsontable(df2)
  })

    }

shinyApp(ui, server)

推荐答案

要连接或附加一个标签与menuItemsubMenuItem,你必须使用tabItemstabItem,而不是tabSetPaneltabPanel.对于布局,您可以将每个rHandsontable包装在column中以使用列布局并设置要用于此表的列的宽度或数量(最多12个).

library(shinydashboard)
library(shiny)
library(rhandsontable)

ui <- dashboardPage(
  dashboardHeader(title = "Assets"),
  dashboardSidebar(
    menuItem("Home", tabName = "home"),
    menuItem("Current assets",
      tabName = "CurrentAssets",
      menuSubItem("Inventory", tabName = "inventory")
    )
  ),
  dashboardBody(
    tabItems(
      tabItem(
        tabName = "inventory",
        column(
          width = 3,
          "df1",
          rHandsontableOutput("Table1")  
        ),
        column(
          width = 3,
          "df2",
          rHandsontableOutput("Table2")
        )
      )
    )
  )
)

server <- function(input, output, session) {
  output$Table1 <- renderRHandsontable({
    rhandsontable(df1)
  })

  output$Table2 <- renderRHandsontable({
    rhandsontable(df2)
  })
}

shinyApp(ui, server)

enter image description here

R相关问答推荐

如何在R中正确对齐放射状图中的文本

具有多个依赖变量/LHS的逻辑模型

无法将传奇添加到cowplot多情节中

获取一个数据库框架的摘要,该数据库框架将包含一列数据库框架,

用黄土法确定区间

从外部文件读取多个值作为字符向量

使用带有OR条件的grepl过滤字符串

哪一行和行和 Select 特定行,但是考虑到Nas

计算直线上点到参考点的总距离

将箭头绘制在图形外部,而不是图形内部

我如何go 掉盒子图底部的数字?

将全局环境变量的名称分配给列表中的所有元素

如何使用For-R循环在向量中找到一系列数字

减go R中列表的所有唯一元素对

如何将一个方阵分解成没有循环的立方体

我如何使用tidyselect来传递一个符号数组,比如Pivot_Long?

使用函数从R中的列中删除标高

如何为包创建自定义roxygen2标签?

如何在R曲线图弹出窗口中更改r和theta标签

如何在类应用函数中访问函数本身