Mercurial > op > ShinyEB
changeset 4:9befa2fab20c
ファイル名を変更
author | uncorrelated zombie <uncorrelated@yahoo.co.jp> |
---|---|
date | Thu, 27 Oct 2022 17:51:15 +0900 |
parents | ab1d3ad46a22 |
children | d37384e7e620 |
files | ShinyEB.R app.R common.R loadLib.R |
diffstat | 4 files changed, 55 insertions(+), 55 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ShinyEB.R Thu Oct 27 17:51:15 2022 +0900 @@ -0,0 +1,46 @@ +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", 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=400, height=400) +} + +app <- shinyApp(ui = ui, server = server) +runApp(app) +
--- a/app.R Thu Oct 27 17:06:50 2022 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -library(shiny) -source("common.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", 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=400, height=400) -} - -app <- shinyApp(ui = ui, server = server) -runApp(app) -
--- a/common.R Thu Oct 27 17:06:50 2022 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -loadLib <- function(...){ - for(lname in unlist(list(...))){ - if(!any(suppressWarnings(library(quietly=TRUE, verbose=FALSE)$results[,"Package"] == lname))){ - stop(sprintf("Do install.packages(\"%s\") before runnning this script.", lname)) - } - library(lname, character.only = TRUE) - } -} -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loadLib.R Thu Oct 27 17:51:15 2022 +0900 @@ -0,0 +1,9 @@ +loadLib <- function(...){ + for(lname in unlist(list(...))){ + if(!any(suppressWarnings(library(quietly=TRUE, verbose=FALSE)$results[,"Package"] == lname))){ + stop(sprintf("Do install.packages(\"%s\") before runnning this script.", lname)) + } + library(lname, character.only = TRUE) + } +} +