在R-Shiny中显示一个非常大的网格表

问题描述 投票:2回答:1

我想在Shiny中显示一个大的网格表,但我找不到办法,因为Shiny似乎总是截断我的表。我使用网格表的原因是它提供了我需要在我的表中实现的一些功能。我设法显示左右视图,但顶部视图始终被截断。这是我的代码:

洋葱:

library(shiny)
library(gridExtra)
library(grid)
library(gtable)

shinyUI(fluidPage(
mainPanel(
  div(class="double-scroll",style='overflow-x:scroll;overflow-y:scroll;
      height:1600px; width:1600px;',plotOutput("out"))
         )
       ))

服务器:

shinyServer(function(input, output,session) {
mat <- matrix(8,nrow=50,ncol=50)
example <- tableGrob(mat,rows=NULL,cols=NULL)
output$out <- renderPlot({grid.draw(example)})
             })

在此示例中,显示了50列“8”,但仅显示了20行。

r shiny large-data r-grid gtable
1个回答
0
投票

尝试这样的代码:

 ui <- fluidPage(
     sidebarLayout(
     sidebarPanel(
          fileInput("file1", "Choose CSV File",
                accept = c("text/csv",
                "text/comma-separated-values,text/plain",
                ".csv")
    ),
    tags$hr(),
    checkboxInput("header", "Header", TRUE)
  ),
  mainPanel(
    tableOutput("contents")
  )
)
)

   server <- function(input, output) {
     output$contents <- renderTable({
     inFile <- input$file1
     if (is.null(inFile))
    return(NULL)
    df <- read.csv(inFile$datapath, header = input$header)
    print(df[,c(1:16)]) # display only the first 16th columns of your dataset
 })
}

shinyApp(ui, server)
© www.soinside.com 2019 - 2024. All rights reserved.