【发布时间】:2021-10-13 13:49:53
【问题描述】:
有没有办法根据从第一个表中选择的行来捕获值。 现在,正在发生的事情仅基于行名称,值会弹出到第二个表中。但这些都是不正确的。请看下文
library(shiny)
library(DT)
library(dplyr)
asd <- data.frame(a = c(7,7,8,8,2,1,3,5,5,6), b = c("A","B","C","A","B","C","A","B","C","F"))
ui <- fluidPage(
selectInput("sel","Slect",choices = asd$b),
dataTableOutput("tab"),
dataTableOutput("txt")
)
server <- function(input, output, session) {
## First table
output$tab <- renderDataTable({
asd <- asd %>% filter(b %in% input$sel)
datatable(asd,selection = 'single')
})
## Second table
output$txt <- renderDataTable({
datatable(asd[rownames(asd) == input$tab_rows_selected,])
})
}
shinyApp(ui, server)
【问题讨论】:
-
嗨@manu p,您能否在问题中同时标记
r和shiny而不仅仅是shiny?谢谢。