|
| 1 | +# |
| 2 | +# This is a Shiny web application. You can run the application by clicking |
| 3 | +# the 'Run App' button above. |
| 4 | +# |
| 5 | +# Find out more about building applications with Shiny here: |
| 6 | +# |
| 7 | +# http://shiny.rstudio.com/ |
| 8 | +# |
| 9 | + |
| 10 | +library(shiny) |
| 11 | + |
| 12 | +# Define UI for application that draws a histogram |
| 13 | +ui <- fluidPage( |
| 14 | + |
| 15 | + # Application title |
| 16 | + titlePanel("JB is the fucking master of the world"), |
| 17 | + |
| 18 | + # Sidebar with a slider input for number of bins |
| 19 | + sidebarLayout( |
| 20 | + sidebarPanel( |
| 21 | + sliderInput("alpha", |
| 22 | + "Valor del parámetro alpha:", |
| 23 | + min = -50, |
| 24 | + max = 50, |
| 25 | + value = 0) |
| 26 | + ), |
| 27 | + |
| 28 | + # Show a plot of the generated distribution |
| 29 | + mainPanel( |
| 30 | + plotOutput("distPlot") |
| 31 | + ) |
| 32 | + ) |
| 33 | +) |
| 34 | + |
| 35 | +# Define server logic required to draw a histogram |
| 36 | +server <- function(input, output) { |
| 37 | + |
| 38 | + output$distPlot <- renderPlot({ |
| 39 | + # generate bins based on input$bins from ui.R |
| 40 | + alpha = input$alpha |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + library(phaseR) |
| 45 | + FHN <- function(t, y, parameters) { |
| 46 | + alpha <- parameters |
| 47 | + dy <- numeric(2) |
| 48 | + dy[1] <- y[1] * (alpha * y[1] + y[2] +1) |
| 49 | + dy[2] <- y[2] * (alpha*y[1] + y[2] - 1) |
| 50 | + return(list(dy)) |
| 51 | + } |
| 52 | + |
| 53 | + phasePlot <- function(FHN, alpha=-1, tmax = 1){ |
| 54 | + FHN.flowField <- flowField(FHN, xlim = c(-3, 3), |
| 55 | + ylim = c(-3, 3), |
| 56 | + xlab="v", ylab="w", |
| 57 | + main=paste0(expression("a="), alpha), |
| 58 | + parameters = alpha, |
| 59 | + points = 15, add = FALSE) |
| 60 | + FHN.nullclines <- nullclines(FHN, xlim = c(-3, 3), |
| 61 | + ylim = c(-3, 3), |
| 62 | + parameters = alpha, |
| 63 | + points = 500) |
| 64 | + y0 <- matrix(c(-2, -2, 0, 0, 0.5, 0.5), |
| 65 | + ncol = 2, nrow = 3, |
| 66 | + byrow = TRUE) |
| 67 | + FHN.trajectory <- trajectory(FHN, y0 = y0, tlim = c(0,tmax), |
| 68 | + parameters = alpha) |
| 69 | + } |
| 70 | + |
| 71 | + phasePlot(FHN, alpha= alpha) |
| 72 | + |
| 73 | + }) |
| 74 | +} |
| 75 | + |
| 76 | +# Run the application |
| 77 | +shinyApp(ui = ui, server = server) |
| 78 | + |
0 commit comments