r - 在 rstudio 查看器中控制数据表输出的高度
问题描述
考虑以下降价文档:
---
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
参数,以便在调整窗口大小时表格缩放,并可能尝试autoWidth
从中删除options
,具体取决于最终产品的外观。
---
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
)
```
推荐阅读
- amazon-web-services - 在我的设备池中哪里可以找到 Amazon 资源编号 (ARN)?
- java - 任务:react-native-gesture-handler:compileDebugJavaWithJavac FAILED
- r - 结构主题建模 (STM):减少 R 中的主题数量
- spring-cloud-dataflow - 如何使用 microk8s 注册 SCDF 应用程序?
- oracle - liquibase 不会在 Oracle DB 12c 上创建 autoIncrement 列
- sql - 有没有办法为 SQL 未发生的订单创建行?
- elasticsearch - 带连字符的 elasticsearch 查询字符串
- python - 使用 Pandas 删除重复项并匹配 2 个 csv 文件的行元素
- firebase - 我的 Nuxt 静态网站的某些页面未显示在 firebase 主机上
- bash - 如何按名称找到匹配的远程分支?