I want to be able to use the selected value from a crosstalk::filter_select in the title of a plot that is based on the sharedData. Here is a minimal example of what I am after (except instead of "x" in the title it is the filtered value).
library(crosstalk)
library(ggplot2)
library(plotly)
shared_mtcars <- SharedData$new(mtcars)
plt <- ggplot(shared_mtcars, aes(wt, mpg))+
geom_point()+
labs(title=paste("Weight vs. MPG for", "x", "cylinder cars."))
bscols(widths = c(3,NA),
list(
crosstalk::filter_select("cyl", "Cylinders", shared_mtcars, ~cyl, multiple = FALSE)
),
ggplotly(plt)
)