2017-05-27 122 views
7

我都含有閃亮-Flexdashboard以下自:表示有如何將renderTable寬度閃亮延長flexdashboard

enter image description here

正如我怎能:

--- 
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

set'width ='200%''也會訣竅。 – parth

+0

以及在'output'中的'orientation:columns'在降序標題中 – parth

回答

5

有趣。如果你看看?mainPanel()的文件。你會看到,寬度爲默認限制爲「8」(12爲最大): mainPanel(..., width = 8)

所以,如果你simplfy更改爲: mainPanel(..., width = 12)它會奏效。

+0

Thanks.How can I make the white area to extend to the full width of the page? – neversaint

+0

今天晚些時候我可以看看。你已經看過這裏:https://stackoverflow.com/questions/15385696/how-to-adjust-the-output-width-of-rstudio-markdown-output-to-html? – BigDataScientist

2

mainPanel中使用width = 12並在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%' 
)) 
) 
``` 

它產生的輸出爲: snapshot

2

我認爲需要注意的是mainPanel是不適合你的使用情況在這裏是非常重要的。這是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%的瀏覽器窗口寬度,而不需要包裝。您可以考慮在FlexDashboard中使用fillPagefluidPage來控制專用於各個元素的大小/區域。

--- 
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" 
) 
```