1
초기화 후 input$some_selection
이 변경되면 첫 번째 관찰자 만 무효화됩니다. 이는 개시시 반응 값 input_some_selection
이 NULL
으로 설정되고 더 이상 업데이트되지 않기 때문인 것으로 보입니다. 라디오 버튼을 누르면시작시 반응 값 처리 NULL을 만듭니다
는, 출력은 다음과 같습니다
[1] "observed at point 1"
[1] "observed at point 2" # as expected until here
[1] "observed at point 1"
# why not invalidate the second observer also?
[1] "observed at point 1"
[1] "observed at point 1"
[1] "observed at point 1"
1) 왜 이런 행동을? 초기 NULL
값 때문입니까?
2) 예제를 적용하려면 무엇을 할 수 있습니까? input$some_selection
이 변경되면 (즉, 의존성 생성시) 두 번째 관찰자를 무효화 할 수 있습니까?
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(),
mainPanel(
radioButtons(inputId = "some_selection",
"Distribution type:",
c("Normal" = "norm",
"Uniform" = "unif",
"Log-normal" = "lnorm"))
)
)
)
server <- function(input, output, session) {
eventlog<-c("")
input_some_selection <- reactive({
input$some_selection
})
observeEvent(input$some_selection, {
print("observed at point 1")
eventlog<<-c(eventlog,"observed at point 1")
})
observeEvent(input_some_selection, {
print("observed at point 2")
eventlog<<-c(eventlog,"observed at point 2")
})
}
shinyApp(ui = ui, server = server)
널 (null)를 확인하는 것이 좋다. 관측 이벤트에서 당신은 이라고 말할 수 있습니다.'if (is.null (input $ some_selection)) return (NULL)'null이 선택되면 "UI에서 선택하십시오" – user5249203