view ShinyEB.R @ 5:d37384e7e620

描画を調整
author uncorrelated zombie <uncorrelated@yahoo.co.jp>
date Thu, 27 Oct 2022 17:52:01 +0900
parents 9befa2fab20c
children 9535740da224
line wrap: on
line source

library(shiny)
source("loadLib.R")
source("EdgeworthBox.R")

loadLib("nleqslv", "shiny")

ui <- fluidPage(
    titlePanel("Edgeworth Box"),

    sidebarLayout(
        sidebarPanel(
            sliderInput("A",
                "initial amount of goods A of person 1",
                min = 0.01,
                max = 0.99,
                value = 0.8), 
            sliderInput("B",
                "initial amount of goods B of person 1",
                min = 0.01,
                max = 0.99,
                value = 0.3),
            checkboxInput("isIP", "Initial Point", TRUE),
            checkboxInput("isIC_I", "Indiffrent Curves pass through the Initial Point", TRUE),
            checkboxInput("isCore", "Core (this works only if the indiffrent curves above were plotted)", TRUE),
            checkboxInput("isIC_E", "Indiffrent Curves pass through the Equilibrium", TRUE),
            checkboxInput("isSHP", "Separating Hyperplane", TRUE),
            checkboxInput("isCC", "Contract Curve", TRUE)
        ), 

        mainPanel(
            plotOutput("distPlot")
        )
    )
)

server <- function(input, output) {
    output$distPlot <- renderPlot({
        # inputにはwithが使えない
        drawEdgeworthBox(input$A, input$B, CC=input$isCC, SHP=input$isSHP, IC_I=input$isIC_I,
            IC_E=input$isIC_E, CORE=input$isCore, IP=input$isIP)
    }, width=500, height=500)
}

app <- shinyApp(ui = ui, server = server)
runApp(app)