Ich entwickle App in Shiny. Ich möchte den Plot mit dem Submit Button darstellen. Ich möchte auch Etiketten drucken, wenn Benutzer das Eingabe-Kontrollkästchen überprüfen. Ich kann Plot per Knopfdruck darstellen. Aber es funktioniert nicht, wenn das Kontrollkästchen aktiviert ist. HierShiny renderPlotly mit zwei Bedingungen
ist der Code:
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))