为什么将 renderPrint() 与 read_csv2 读取的 .csv 文件结合使用会在我的输出中产生一个奇怪的索引栏?

Why does using renderPrint() in combination with a .csv file read by read_csv2 produce a strange indexing bar in my output?

当我将 renderPrint() 与用户上传并由 read_csv2() 阅读的 .csv 文件结合使用时,我遇到了问题。我总是在实际输出之前得到一种奇怪的索引栏。

当我用基数 R 的 read.csv2() 替换 read_csv2() 时,索引栏消失了。因此,我的猜测是这个问题在某种程度上与 read_csv2().csv 文件读取为 tibble 而不是 data.frame 这一事实有关。 或者,我也试过vroom::vroom(),但是进度条的问题依然存在

在我的应用程序中,我想使用 read_csv2()vroom::vroom(),因为它们都明显快于 read.csv2()

我的代表:

library(shiny)
library(readr)

ui <- fluidPage(
  fileInput(
    inputId = "upload",
    label = "Upload file:"
  ),
  verbatimTextOutput("text")
)


server <- function(input, output, session) {
  data <- reactive({
    req(input$upload)
    read_csv2(input$upload$datapath)
  })

  output$text <-
    renderPrint({
      class(data())
    })
}


shinyApp(ui, server)

Shiny 应用程序中的输出:

indexing 0.csv [============================================================================================] ?, eta:  0s
                                                                                                                         
[1] "spec_tbl_df" "tbl_df"      "tbl"         "data.frame" 

进度条默认由readr包显示。您可以使用 options.

禁用它们
options(readr.show_progress = FALSE)