1
다른 객체/입력 (결과가 쉽게 추적되지 않는 버튼, 예 : 온라인 데이터)을 변경하는 주요 객체를 변경해야하는 shinyapp가 있습니다.). 그래서 버튼 입력을 사용해야했습니다. 모든 버튼의 코드를 다시 작성하지 않고도 주 객체를 업데이트 할 수 있습니까? c()
를 사용하여 예를 들어, 당신은 단순히 두 버튼 식을반짝이는 객체 반응성 여러 입력 (버튼)에 대한 반응성
library(datasets)
library(shiny)
ui<-fluidPage(
titlePanel("Telephones by region"),
sidebarLayout(
sidebarPanel(
selectInput("region", "Region:",
choices=colnames(WorldPhones)),
helpText("Data from AT&T (1961) The World's Telephones."),
actionButton("submit",
label = "submit"), # this also has other functions
actionButton("change",
label = "change") # this also has other functions
),
mainPanel(
plotOutput("phonePlot")
)
)
)
server<-function(input, output) {
data<-reactiveValues()
observeEvent(input$submit,{
data$data<-WorldPhones[,input$region]
})
observeEvent(input$change,{
data$data<-WorldPhones[,input$region]
})
output$phonePlot <- renderPlot({
if(!is.null(data$data))
barplot(data$data*1000,
ylab="Number of Telephones",
xlab="Year")
})
}
shinyApp(ui = ui, server = server)