2 개의 탭이있는 앱이 있으며 각각 액션 버튼이 있습니다. 두 단추 중 하나를 누르면 동일한 프로세스가 실행되기를 원합니다. 그래서 나는 그에게 다음과 같은 방법으로 썼다 :2 개의 탭에 2 개의 액션 버튼이있는 eventReactive
library(shiny)
ui <- fluidPage(
tabsetPanel(
tabPanel("tab1",
actionButton("btn1","Button 1"),
textOutput("text")
),
tabPanel("tab2",
actionButton("btn2","Button 2")
)
)
)
server <- function(input, output) {
data=eventReactive(c(input$btn1,input$btn2),{
print("Button is pressed!")
print(input$btn1)
print(input$btn2)
iris
})
output$text=renderText({
req(data())
print(head(data()))
"Really? Button is pressed!"
})
}
# Run the application
shinyApp(ui = ui, server = server)
을 그리고 eventReactive
표현이 트리거 왜 응용 프로그램은 초기화 상태에서 버튼을 누르면 전에 나는 이해가 안 돼요.
버튼 1 개 (예 : c(input$btn1, input$btn2)
) 대신 input$btn1
인 경우 두 가지 종속성이있는 것은 아닙니다.
누군가 나를 밝힐 수 있습니까?
이 솔루션이 효과가 있다고 생각하지 않습니다. 방아쇠를 'AND'상태로 만듭니다. 즉, 어떤 일이 일어나기 전에 두 버튼을 모두 눌러야합니다. 물론 이것이 왜 그런지 이해할 수 없습니다. – qoheleth