BUG:Shiny tableOutput在0行data.frame上给出错误

时间:2014-09-02 21:51:36

标签: r shiny xtable

(这是报告闪亮错误的正确位置吗?)

tableOutput在传递0行data.frame:

时给出以下错误
Warning in matrix(align.tmp[(2 - pos):(ncol(x) + 1)], nrow = nrow(x), ncol = ncol(x) +  :
   data length exceeds size of matrix

ui.R:

library(shiny)
shinyUI(fluidPage(
    mainPanel(
      tableOutput("view"))))

server.R:

library(shiny)
shinyServer(function(input, output) {
    output$view <- renderTable({data.frame(col=character(0))})
})

sessionInfo:

R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_0.10.1

loaded via a namespace (and not attached):
[1] RJSONIO_1.2-0.2 Rcpp_0.11.2     bitops_1.0-6    caTools_1.17   
[5] digest_0.6.4    htmltools_0.2.4 httpuv_1.3.0    tools_3.1.0    
[9] xtable_1.7-3   

1 个答案:

答案 0 :(得分:2)

这不是shiny而是xtable

的问题
> library(xtable)
> rr <-xtable(data.frame(col=character(0)))
> print(rr, type = 'html')
<!-- html table generated in R 3.1.1 by xtable 1.7-3 package -->
<!-- Wed Sep 03 00:22:48 2014 -->
<TABLE border=1>
<TR> <TH>  </TH> <TH> col </TH>  </TR>
  </TABLE>
Warning message:
In matrix(align.tmp[(2 - pos):(ncol(x) + 1)], nrow = nrow(x), ncol = ncol(x) +  :
  data length exceeds size of matrix

这也不是错误而是警告。