0
如何使畫筆工作並將所選點突出顯示爲紅色。R閃亮的ggplot畫筆
看來brushedPoints
函數工作不正常。
library(shiny)
library(ggplot2)
server <- function(input, session, output) {
D = reactive({
brushedPoints(mtcars,input$brush_1, allRows = TRUE)
})
output$Plot = renderPlot({
set.seed(1)
X = D()
X[,"cyl"] = as.character(X[,"cyl"])
ggplot(X,aes_string(x="cyl",y="mpg")) +
geom_boxplot(outlier.shape = NA) +
geom_jitter(aes(color = selected_))+
scale_color_manual(values = c("black","red"),guide=FALSE)
})
output$log = renderPrint({
input$brush_1
})
output$Data = renderPrint({
D()
})
}
ui <- fluidPage(
plotOutput("Plot",brush = "brush_1"),
verbatimTextOutput("Data"),
verbatimTextOutput("log")
)
shinyApp(ui = ui, server = server)