library(shiny)
library(dplyr)
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
DBI::dbWriteTable(con, "cars", cars)
ui <- fluidPage(
numericInput("speed", "speed", 15),
tableOutput("table")
)
server <- function(input, output, session) {
my_speed <- reactive({
input$speed
})
output$table <- renderTable({
tbl(con, "cars") %>%
filter(speed == my_speed()) %>%
collect()
})
}
shinyApp(ui, server)
Below is a simple reprex
It produces an error
no such function: my_speed. It looks like dbplyr thinks that my reactive is a database table? 😕 Note that if I save the reactive value to a local variable earlier and use that variable, then it does work. But it seems strange that I won't be able to use reactives in my sql, and I couldn't find any documentation suggesting this is expected.