![](/img/trans.png)
[英]How to specify the width/height of the shiny viewer window created by rstudio?
[英]Control height of datatableoutput in rstudio viewer
考虑以下降价文档:
---
title: "R Notebook"
output: html_notebook
---
```{r}
library(shiny)
ui <- fluidPage(
DT::dataTableOutput("tbl")
)
server <- function(input, output, session){
output$tbl = DT::renderDataTable(
mtcars,
server = FALSE,
selection = list(mode = "multiple", target = "column", selected = c(1)),
options = list(pageLength = 10, autoWidth = TRUE)
)
}
runApp(
appDir = shinyApp(ui, server),
launch.browser = rstudioapi::viewer
)
```
如果我从 rmarkdown 运行闪亮的应用程序,则表格未完全显示。 如果我点击“在浏览器中打开”,一切都会很好。
题:
如果我从 rmarkdown 调用应用程序,如何在查看器中的整页上显示表格?
我认为最简单的方法是将height
添加到dataTableOutput
。 你可以玩弄这个数字,也可以试试“rem”、“px”等等——“em”对我来说效果最好。 您可能还想尝试添加width
参数,以便在调整窗口大小时表格会缩放,并且可能尝试从options
删除autoWidth
,具体取决于最终产品的外观。
---
title: "R Notebook"
output: html_notebook
---
```{r}
library(shiny)
ui <- fluidPage(
DT::dataTableOutput("tbl", height = "40em")
)
server <- function(input, output, session){
output$tbl = DT::renderDataTable(
mtcars,
server = FALSE,
selection = list(mode = "multiple", target = "column", selected = c(1)),
options = list(pageLength = 10, autoWidth = TRUE)
)
}
runApp(
appDir = shinyApp(ui, server),
launch.browser = rstudioapi::viewer
)
```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.