光沢のあるアプリケーションで反応性のあるデータセットを使用して、そのデータセットを使用する他のオブジェクトをreactiveDf
の値に従って再レンダリングできるようにしたいと思います。Shinyでデータセットを反応させるにはどうすればいいですか?
この例では1つのテーブルだけを出力していますが、私のアプリでは他のチャートとテーブルがあり、その考え方はサブセットreactiveDf
でレンダリングをトリガーすることです。また、私はdplyr
を使ってそれをしたいと思います。今
library(shiny)
library(dplyr)
ui <- shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
checkboxGroupInput('Category', '',
unique(mtcars$carb), selected = unique(mtcars$carb))),
# Show table of the rendered dataset
mainPanel(
tableOutput("df")
)
)
))
server <- shinyServer(function(input, output) {
reactiveDf <- reactive({tbl_df(mtcars) %>%
filter(carb %in% input$Category)})
output$df <- renderTable({reactiveDf})
})
shinyApp(ui = ui, server = server)
私はこのアプリを実行すると、私が手:
Listening on http://127.0.0.1:7032
Warning: Error in UseMethod: no applicable method for 'xtable'
applied to an object of class "reactive"
そしてtableOutput()
は表示されません。
@coryを必要とする...機能ですと 'data.frame'です。あなたは、そのオブジェクトがデータフレームだけを必要とすることを意味しますか? 元のアプリケーションでggvisも使用しています。そのため、サブセット化のためにdplyrを使用しようとしていました。 – Dambo