R markdown:将 html table 下载到 excel 文件

R markdown: download a html table to an excel file

我有一个 R markdown,我在其中构建了一个 table,我想添加将 table 下载到 excel 文件的选项。

kable(MyTable) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", 
  "responsive")) %>%
  scroll_box(width = "900px", height = "500px")

您可以随时尝试使用 DT::datatable 获取导出按钮

MyTable %>%
  DT::datatable(
    extensions = 'Buttons', 
    options = list(dom = 'Bfrtip', 
                   buttons = c('excel', "csv")))