【问题标题】:Display a very large grid table in R-Shiny在 R-Shiny 中显示一个非常大的网格表
【发布时间】:2017-02-14 10:46:09
【问题描述】:

我想在 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)})
             })

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

【问题讨论】:

    标签: r shiny large-data r-grid gtable


    【解决方案1】:

    试试这样的代码:

     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)
    

    【讨论】:

      猜你喜欢
      • 2020-04-28
      • 1970-01-01
      • 2018-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多