Shiny

한 번도 사용해 본 적이 없는 상태에서 시도하는 것이라서 헷갈렸는데 대충 방법을 알 것 같다.

library(shiny)

 ui <- fluidPage(
   sliderInput("tmpa", "# of Arrow", min = 50, max = 500000, value = 50)
   , plotOutput("myPlot")
 ) 
 
server <- function(input, output, session) { 
   output$myPlot = renderPlot({
     tmpa = input$tmpa
     x = runif(tmpa)
     y = runif(tmpa)
     ok = x^2 + y^2 <= 1
     plot(x, y, pch=".", col=ifelse(ok, "red", "blue"), main=paste(4*sum(ok)/tmpa), asp=1, xlim=c(0, 1), ylim=c(0, 1))
   })
 } 

 shinyApp(ui, server)