0
나는 반짝이는 앱을 개발 중이다. 제출 버튼을 사용하여 플롯을 렌더링하고 싶습니다. 또한 사용자가 inputcheckbox를 확인하면 레이블을 인쇄하려고합니다. 버튼을 통해 플롯을 렌더링 할 수 있습니다. 그러나 체크 박스가 선택되면 작동하지 않습니다. 내가 더 빛나는 전문가는 아니지만Shiny renderPlotly with two conditions
library(shiny)
library(plotly)
ui <- fluidPage(
actionButton('RUN', 'Run'),
checkboxInput('PrintLab', 'Label', FALSE),
plotlyOutput("plot1")
)
server = function(input, output) {
output$plot1 <- renderPlotly({
req(input$RUN)
isolate({
ggplotly(ggplot(data = mtcars, aes(wt, hp)) +
geom_point(size=1, colour = "grey"))
})
req(input$PrintLab)
isolate({
ggplotly(ggplot(data = mtcars, aes(wt, hp)) +
geom_point(size=1, colour = "grey") +
geom_text(aes(label=wt), size=3, colour = "black"))
})
})
}
runApp(shinyApp(ui, server))