|
| 1 | +# |
| 2 | +# This is the server logic of a Shiny web application. You can run the |
| 3 | +# application by clicking 'Run App' above. |
| 4 | +# |
| 5 | +# Find out more about building applications with Shiny here: |
| 6 | +# |
| 7 | +# http://shiny.rstudio.com/ |
| 8 | +# |
| 9 | + |
| 10 | +library(shiny) |
| 11 | +SciViews::R() |
| 12 | + |
| 13 | +# Define server logic required to draw a histogram |
| 14 | +shinyServer(function(input, output) { |
| 15 | + |
| 16 | + output$trees_plot <- renderPlot({ |
| 17 | + |
| 18 | + set.seed(42) |
| 19 | + micmen_exo <- tibble( |
| 20 | + conc = seq(0, 25, by = 0.1), |
| 21 | + vitesse = SSmicmen(conc, Vm = 6, K = 2) + rnorm(n = length(conc), sd = 0.05), |
| 22 | + vit_predit = SSmicmen(conc, Vm = input$vm_ui, K = input$k_ui) |
| 23 | + ) |
| 24 | + |
| 25 | + chart::chart(micmen_exo, vitesse ~ conc) + |
| 26 | + ggplot2::geom_point() + |
| 27 | + geom_line(f_aes(vit_predit ~ conc), color = "red") + |
| 28 | + xlab("Concentration [mol/L]") + |
| 29 | + ylab("Vitesse [mol/min]") |
| 30 | + }) |
| 31 | + |
| 32 | + output$micmen_model <- renderUI({ |
| 33 | + withMathJax( |
| 34 | + sprintf("Ton modèle : $$Vitesse \\ = \\frac{%.02f* concentration}{%.02f + concentration}$$", |
| 35 | + input$vm_ui, input$k_ui)) |
| 36 | + }) |
| 37 | + |
| 38 | + |
| 39 | + output$micmen_resid <- renderUI({ |
| 40 | + set.seed(42) |
| 41 | + micmen_exo <- tibble( |
| 42 | + conc = seq(0, 25, by = 0.1), |
| 43 | + vitesse = SSmicmen(conc, Vm = 6, K = 2) + rnorm(n = length(conc), sd = 0.05), |
| 44 | + vit_predit = SSmicmen(conc, Vm = input$vm_ui, K = input$k_ui), |
| 45 | + distance2 = (vit_predit - vitesse)^2 |
| 46 | + ) |
| 47 | + |
| 48 | + value <- sum(micmen_exo$distance2) |
| 49 | + |
| 50 | + withMathJax( |
| 51 | + sprintf("La valeur de la somme des résidus au carré de ton modèle : $$%.05f$$", |
| 52 | + value)) |
| 53 | + }) |
| 54 | + |
| 55 | + |
| 56 | + output$micmen_theo <- renderPlot({ |
| 57 | + |
| 58 | + micmen_data <- tibble( |
| 59 | + conc = seq(0, 15, by = 0.1), |
| 60 | + v = SSmicmen(conc, Vm = 1, K = 0.5) |
| 61 | + ) |
| 62 | + |
| 63 | + chart(data = micmen_data, v ~ conc) + |
| 64 | + geom_line() + |
| 65 | + labs( x = "x [input]", y = "y") + |
| 66 | + geom_vline(xintercept = 0, col = "darkgray") + |
| 67 | + geom_hline(yintercept = c(0.5, 1), col = "gray", linetype = "dashed") + |
| 68 | + geom_vline(xintercept = 0.4, col = "gray", linetype = "dashed") + |
| 69 | + annotate("text", label = "Vm", x = -0.4, y = 1) + |
| 70 | + annotate("text", label = "Vm/2", x = -0.5, y = 0.55) + |
| 71 | + annotate("text", label = "K", x = 0.5, y = 0.04) |
| 72 | + }) |
| 73 | + |
| 74 | +}) |
0 commit comments