Hi - I'm reviewing this article on "Modularizing Shiny app code" Shiny - Modularizing Shiny app code and noticed that the linked to example (here: Shiny - Module example) uses older deprecated code such as using CallModule() instead of ModuleServer() and the scatterPlot() custom function uses aes_string() instead of using tidy evaluation idioms instead.
I've fixed the code to use ModuleServer() and that works fine, but when I try to fix the aes_string to call aes() instead I get an error from the brushedPoint() function:
Warning: Error in brushedPoints: brushedPoints: xvar
('.data[["cty"]]') not in names of input
The function plots fine on first call when there are no points selected with the brush, but once brushed the brushedPoints() function doesn't know how to evaluate unless I use the deprecated aes_string() function.
Does anyone know how to get this code to work without using the deprecated aes_string() function? It would be nice if the example code for the article was updated to reflect the content of the article.
Here is my modification for reference. The rest of the code is basically the same as the example except I utilized the ModuleServer() function and got rid of the CallModule() function.
scatterPlot <- function(data, cols) {
ggplot(data, aes(x = .data[[cols[1]]], y = .data[[cols[2]]])) +
geom_point(aes(color = selected_)) +
scale_color_manual(values = c("black", "#66D65C"), guide = FALSE)
}