0
두 개의 출력물 인 인쇄물과 플롯이 있습니다. 실행 버튼을 누른 후 (작업 중) 프린트를 실행하고 프린트가 완료되면 플롯 파트가 실행됩니다.다른 마무리 후 반짝 반짝 빛납니다.
이유는 인쇄 부분이 몇 분이 걸리는 계산을 수행하기 때문에 그 출력이 plot 명령으로 이동해야하기 때문입니다.
간단한 예 :
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
actionButton('run','Run')
),
mainPanel(
verbatimTextOutput("Descriptive"),
plotOutput("plotData",width = "700px", height = "500px")
)
)
)
server <- function(input, output) {
output$Descriptive <- renderPrint({
if(input$run>0){
return(isolate({
cat('Number of rows:', nrow(mtcars))
mpg2 <<- mtcars$mpg+3
cyl2 <<- mtcars$cyl+3
}))
}else{return(invisible())}
})
#### RUN AFTER DESCRIPTIVE COMPLETES ####
output$plotData <- renderPlot({
plot(mpg2,cyl2)
})
}
shinyApp(ui = ui, server = server)
이 출력 후 사용할 수 있습니다 반응 식으로 계산을 돌립니다. 계산이 변경 될 때마다 계산에 의존하는 출력이 자동으로 업데이트됩니다. https://shiny.rstudio.com/articles/reactivity-overview.html을 한 눈에 볼 수 있습니다. –