我有以下自己包含Shiny-Flexdashboard:
---
title: "FOO"
runtime: shiny
output:
flexdashboard::flex_dashboard:
vertical_layout: scroll
orientation: rows
theme: default
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
```
Rows
-------------------------------------
### Statistical Test Summary
```{r stat_test_table}
mainPanel(
renderTable( {
dat <- df <- structure(list(`Sample name` = structure(1:3, .Label = c("Sample1",
"Sample2", "Sample3"), class = "factor"), `FDR correction (mean)` = c(5.93070861978308e-15,
6.88632524238004e-13, 3.28339498763286e-16), `FDR correction (sd)` = c(2.00046170407461e-14,
2.32019633515427e-12, 1.10782095003689e-15), `P-value (mean)` = c(5.55365134900322e-15,
6.44757191496266e-13, 3.07475941705412e-16), `P-value (sd)` = c(1.98732517127302e-14,
2.30494707691577e-12, 1.10054774779699e-15)), class = c("tbl_df",
"tbl", "data.frame"), .Names = c("Sample name", "FDR correction (mean)",
"FDR correction (sd)", "P-value (mean)", "P-value (sd)"), row.names = c(NA, -3L))
}
, digits=-2, width = '100%'
)
)
```
它产生这样的表:
如上所述,我如何扩展列宽?
答案 0 :(得分:6)
有趣。如果你看一下?mainPanel()
的文件。您将看到宽度默认限制为&#34; 8&#34; (12是最大值):
mainPanel(..., width = 8)
所以,如果你简单地改为:
mainPanel(..., width = 12)
它会起作用。
答案 1 :(得分:2)
在width = 12
中使用mainPanel
并在div
内附上表格就可以了。
---
title: "FOO"
runtime: shiny
output:
flexdashboard::flex_dashboard:
vertical_layout: scroll
orientation: columns
theme: default
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
```
Columns
-------------------------------------
### Statistical Test Summary
```{r stat_test_table}
mainPanel(width = 12,
div(style="height:570px",
renderTable( {
dat <- df <- structure(list(`Sample name` = structure(1:3, .Label = c("Sample1",
"Sample2", "Sample3"), class = "factor"), `FDR correction (mean)` = c(5.93070861978308e-15,
6.88632524238004e-13, 3.28339498763286e-16), `FDR correction (sd)` = c(2.00046170407461e-14,
2.32019633515427e-12, 1.10782095003689e-15), `P-value (mean)` = c(5.55365134900322e-15,
6.44757191496266e-13, 3.07475941705412e-16), `P-value (sd)` = c(1.98732517127302e-14,
2.30494707691577e-12, 1.10054774779699e-15)), class = c("tbl_df",
"tbl", "data.frame"), .Names = c("Sample name", "FDR correction (mean)",
"FDR correction (sd)", "P-value (mean)", "P-value (sd)"), row.names = c(NA, -3L))
}
, digits=-2, width = '100%'
))
)
```
答案 2 :(得分:2)
我认为重要的是要注意mainPanel
不是针对您的用例而设计的。这是&#34;正确的&#34; mainPanel
的使用以及默认width = 8
sidebarLayout(
sidebarPanel(sliderInput("thing", "Thing", min = 0, max = 5, value = 4)),
mainPanel(
renderDataTable( {
input$Thing
dat <- df <- structure(list(`Sample name` = structure(1:3, .Label = c("Sample1",
"Sample2", "Sample3"), class = "factor"), `FDR correction (mean)` = c(5.93070861978308e-15,
6.88632524238004e-13, 3.28339498763286e-16), `FDR correction (sd)` = c(2.00046170407461e-14,
2.32019633515427e-12, 1.10782095003689e-15), `P-value (mean)` = c(5.55365134900322e-15,
6.44757191496266e-13, 3.07475941705412e-16), `P-value (sd)` = c(1.98732517127302e-14,
2.30494707691577e-12, 1.10054774779699e-15)), class = c("tbl_df",
"tbl", "data.frame"), .Names = c("Sample name", "FDR correction (mean)",
"FDR correction (sd)", "P-value (mean)", "P-value (sd)"), row.names = c(NA, -3L))
}
)
)
)
此外,如果您使用DT :: renderDataTable,您可以更灵活地使用表格https://rstudio.github.io/DT/
实际上,默认情况下,这需要100%的浏览器窗口宽度而不需要包装器。您可以考虑在flexdashboards中使用fillPage
和fluidPage
来控制专用于各个元素的大小/区域。
---
title: "FOO"
runtime: shiny
output:
flexdashboard::flex_dashboard:
vertical_layout: scroll
orientation: rows
theme: default
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(DT)
```
Rows
-------------------------------------
### Statistical Test Summary
```{r}
DT::renderDataTable( {
input$Thing
dat <- df <- structure(list(`Sample name` = structure(1:3, .Label = c("Sample1",
"Sample2", "Sample3"), class = "factor"), `FDR correction (mean)` = c(5.93070861978308e-15,
6.88632524238004e-13, 3.28339498763286e-16), `FDR correction (sd)` = c(2.00046170407461e-14,
2.32019633515427e-12, 1.10782095003689e-15), `P-value (mean)` = c(5.55365134900322e-15,
6.44757191496266e-13, 3.07475941705412e-16), `P-value (sd)` = c(1.98732517127302e-14,
2.30494707691577e-12, 1.10054774779699e-15)), class = c("tbl_df",
"tbl", "data.frame"), .Names = c("Sample name", "FDR correction (mean)",
"FDR correction (sd)", "P-value (mean)", "P-value (sd)"), row.names = c(NA, -3L))
},
extensions = "Responsive"
)
```