When I create a group of linked boxplots( selecting points in one boxplot highlights the corresponding points in all boxplots), the boxplots keep updating themselves for a uncertain amount of times (sometimes only once but sometimes up to 20 times).
Please run the following sample code.
I believe the source of problem is the geom_jitter(). Is there any way to stop the boxplots from updating themselves? Thanks.
library(shiny)
library(ggplot2)
server <- function(input, session, output) {
X = data.frame(x1 = rnorm(1000),
x2 = rnorm(1000),
week = sample(LETTERS[1:10],1000,replace = TRUE)
)
D = reactive({
brushedPoints(X,input$brush_1, allRows = TRUE)
})
output$p1 = renderPlot({
set.seed(123)
ggplot(D(),aes(x=week,y=x1))+
geom_boxplot() +
geom_jitter(aes(color=selected_))+
scale_color_manual(values = c("black","red"),guide=FALSE)
})
output$p2 = renderPlot({
set.seed(123)
ggplot(D(),aes(x=week,y=x2))+
geom_boxplot() +
geom_jitter(aes(color=selected_))+
scale_color_manual(values = c("black","red"),guide=FALSE)
})
}
ui <- fluidPage(
splitLayout(
plotOutput("p1",brush = "brush_1"),
plotOutput("p2",brush = "brush_1")
)
)
shinyApp(ui = ui, server = server)
Update: 2016-9-16
I tried replacing geom_jitter
with geom_point
, but the charts still keep updating themselves.
So geom_jitter
may not be the suspect.
So what is the source of problem on earth?