我有一个Shiny server,运行着一堆包含一个表的选项卡。这些表的内容根据 sidebarPanel 上用户的选择而动态变化。我正在使用 gvisTable ,但是我不介意更改库。

动态选择可以使给定表中的列数和行数发生显着变化,有时列数多而行数少,因此将可视化转置后的数据框而不是原始数据框会更容易。

如何在页面上添加开关,以便有条件地将所选数据框显示为原始格式或转置版本?

例如。原始表和转置表:

+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
| Id       | Column1  | Column2  | Column3  | Column4  | Column5  | Column6  | Column7  | Column8  | Column9  |
+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
| 1        |  4       |  5       |   6      |   8      |   2      |   2      |     4    |    44    |   5      |
+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+
| 2        |  6       |  7       |   7      |   7      |   44     |   4      |    55    |     5    |   2      |
+----------+----------+----------+----------+----------+----------+----------+----------+----------+----------+

+----------+----------+----------+
| Id       |  1       |  2       |
+----------+----------+----------+
| Column1  |  4       |  6       |
+----------+----------+----------+
| Column2  |  5       |  7       |
+----------+----------+----------+
| Column3  |  6       |  7       |
+----------+----------+----------+
| Column4  |  8       |  7       |
+----------+----------+----------+
| Column5  |  2       |  44      |
+----------+----------+----------+
| Column6  |  2       |  4       |
+----------+----------+----------+
| Column7  |  4       |  55      |
+----------+----------+----------+
| Column8  |  44      |  5       |
+----------+----------+----------+
| Column9  |  5       |  2       |
+----------+----------+----------+

最佳答案

您是否正在将数据帧传递给gvisTable?如果是这样,为什么不直接传入t(your_dataframe)呢?

关于r - 带移调开关的R Shiny table ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21329070/

10-12 18:48