如何很好地旋转DT数据表,以便垂直滚动

问题描述

我的闪亮应用中有一个DT renrered,它的列很多。

 mtcars2 <- cbind(mtcars,mtcars)
 mtcars2 <- cbind(mtcars,mtcars2)

enter image description here

我希望表被反转,因为列名将是第一列,然后所有记录都是垂直的,所以我不需要水平而是垂直滚动。

enter image description here

我仍然希望mpg成为列,cyl成为列等。只是显示表格的方式是相反的。

在DT中可行吗?

谢谢

解决方法

您可以使用CSS属性transform进行旋转:

  div(
    style = "transform: rotateZ(-90deg); transform-origin: bottom;",DTOutput("yourOutputId")
  )
,

t用于转置。使用基数R中的t(...)函数。

mtcars2 <- cbind(mtcars,mtcars)
mtcars2 <- cbind(mtcars,mtcars2)

mtcars_t <- t(mtcars2)