shiny
以下のアプリでは、最初のテーブルの行をクリックすると、対応するspecies
列の値を取得する必要があります。次に、この値を使用df
して、species
列に基づいて2番目のデータフレームをサブセット化する必要があります。
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(DT::dataTableOutput('tableId'),
dataTableOutput("celltext")),
server = function(input, output) {
output$tableId = DT::renderDataTable(
iris[,c(1,5)], selection = list(target = 'row',mode="single")
)
species<-c("setosa","setosa","virginica","virginica")
flower<-c("a","b","c","d")
score<-c(7,5,6,9)
df<-data.frame(species,flower,score)
output$celltext <- renderDataTable({
cell <- input$tableId_rows_selected
df<-df[df$species == iris[row]
})
}
)
これを試して
shinyApp(
ui = fluidPage(DT::dataTableOutput('tableId'),
DTOutput("celltext")),
server = function(input, output) {
output$tableId = DT::renderDataTable(
iris[,c(1,5)], selection = list(target = 'row',mode="single")
)
species<-c("setosa","setosa","virginica","virginica")
flower<-c("a","b","c","d")
score<-c(7,5,6,9)
df<-data.frame(species,flower,score)
output$celltext <- renderDT({
cell <- input$tableId_rows_selected
dat<-df[df$species %in% iris[cell,5],]
dat
})
}
)
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加