gpt4 book ai didi

r - 在 Shiny dataTableOutput 中控制表格宽度

转载 作者:行者123 更新时间:2023-12-03 23:08:44 27 4
gpt4 key购买 nike

我无法控制使用函数 dataTableOutput() 添加到 Shiny 应用程序的数据表的宽度.我尝试使用 width函数中的参数,但它在输出中没有任何改变,也没有错误 ~ 它没有告诉我它忽略了 width范围。

library(shiny)
library(shinythemes)

ui <- fluidPage(theme = shinytheme("Spacelab"),
fluidRow(
column(6,dataTableOutput(outputId = "table")),
column(6,p(textOutput("para")))
)
)

server <- function(input, output){

df <- as.data.frame(matrix(0, ncol = 15, nrow = 20))

output$table <- renderDataTable({df})

output$para <- renderText({
text <- rep(x = "Hello World",1000)
})
}
shinyApp(ui = ui,server = server)

最佳答案

如果您使用“DT”R 包,以及相应的 DT::dataTableOutputDT::renderDataTable ,您可以在这些调用中使用“宽度”选项,这显然可以是 %(例如宽度 =“100%”)或像素(宽度 = 300),它应该可以让您获得所需的控制。

看:
https://rstudio.github.io/DT/shiny.html

该页面的注释:

Important: Be sure to use the DT:: prefix when calling dataTableOutput and renderDataTable so that the DT versions of these functions are guaranteed to be called, instead of the deprecated Shiny versions. If you make sure to library(DT) after library(shiny), normally the DT versions should just override the shiny versions if you do not use the DT:: prefix (when in doubt, use this prefix, until we completely remove these functions from shiny)

关于r - 在 Shiny dataTableOutput 中控制表格宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32149487/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com