【问题标题】:get selected row in a datatable in an interactive document using Rmarkdown and shiny使用 Rmarkdown 和闪亮获取交互式文档中数据表中的选定行
【发布时间】:2016-03-25 08:35:15
【问题描述】:

我正在使用 Rmarkdown 和 Shiny 探索在交互式文档中使用 DT:datatable(我之前没有使用过 datatable)。

我能够创建一个绘制数据表的文档:

---
title: "Test DT"
output: html_document
runtime: shiny
---

```{r echo=FALSE}
datatable(iris)
```

单击数据表中的一行会突出显示一行。有没有办法在不实现闪亮服务器的情况下访问选定的行?怎么样?

【问题讨论】:

    标签: r shiny r-markdown dt


    【解决方案1】:

    您必须使用 output$id 才能使其工作。你会怎么做呢

    ---
    title: "Test DT"
    output: html_document
    runtime: shiny
    ---
    
    ```{r echo=FALSE}
    
    library(DT)
    
    DT::dataTableOutput('irisTable')
    output$irisTable = DT::renderDataTable(iris, selection = 'multiple')
    
    p("By default DT allows multiple row selection. Selected rows are...")
    renderPrint(input$irisTable_rows_selected)
    
    ```
    

    DT 还允许选择列和单元格以及预选。见documentation

    【讨论】:

      猜你喜欢
      • 2017-09-16
      • 2014-08-09
      • 2018-02-18
      • 2016-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-01
      • 1970-01-01
      相关资源
      最近更新 更多