如何将闪亮的数据表从垂直放置变为水平放置?

问题描述 投票:0回答:1

enter image description here

output$table2<- renderTable(asdf_lm$fitted)
我该如何翻转这张桌子?就是图中第二个,单柱的。

尝试获取单行。让数据更适合屏幕。

r shiny
1个回答
0
投票

假设我正确理解您的问题(请下次发布一个最小的可重现示例),您可以使用

t()
来转置您要显示的数据。

您似乎想显示来自

lm()
模型拟合的拟合数据。

这是一个带有

mtcars
数据集的示例:

library(shiny)

if (interactive()) {
  shinyApp(
    ui = fluidPage(
      fluidRow(
        column(12,
          tableOutput('table')
        )
      )
    ),
    server = function(input, output) {
        output$table <- renderTable({
            mod <- lm(mpg ~ cyl, data = mtcars)

            # Here you transpose your data.
            t(mod$fitted)
        })
    }
  )
  }

结果:

© www.soinside.com 2019 - 2024. All rights reserved.