1- learndown :: learndownShinyVersion(" 1.0 .0" )
1+ learndown :: learndownShinyVersion(" 1.1 .0" )
22conf <- BioDataScience :: config()
33
44library(shiny )
@@ -16,6 +16,11 @@ model_data <- tibble::tibble(
1616 y = SSlogis(x , Asym = asym_init , xmid = xmid_init , scal = scal_init ) +
1717 rnorm(n = length(x ), sd = error_sd ))
1818
19+ graph <- chart :: chart(model_data , y ~ x ) +
20+ ggplot2 :: geom_point() +
21+ ggplot2 :: xlab(" x" ) +
22+ ggplot2 :: ylab(" y" )
23+
1924ui <- fluidPage(
2025 learndownShiny(" Ajustement manuel d'un modèle : courbe logistique" ),
2126
@@ -29,7 +34,7 @@ ui <- fluidPage(
2934 sliderInput(" xmid" , label = " Xmid" ,
3035 value = 1.00 , min = 0.25 , max = 10.00 , step = 0.25 ),
3136 sliderInput(" scal" , label = " Scal" ,
32- value = 1.00 , min = 0.25 , max = 10 .00 , step = 0.25 ),
37+ value = 1.00 , min = - 2.00 , max = 6 .00 , step = 0.25 ),
3338
3439 hr(),
3540
@@ -79,17 +84,18 @@ server <- function(input, output, session) {
7984
8085 output $ model_plot <- renderPlot({
8186 data <- model_predict()
87+ p <- graph
8288
83- chart :: chart( data , y ~ x ) +
84- ggplot2 :: geom_point() +
85- ggplot2 :: geom_line(chart :: f_aes(y_predit ~ x ), color = " red" ) +
86- ggplot2 :: xlab( " x " ) +
87- ggplot2 :: ylab( " y " )
89+ if ( ! any(is.nan( data $ y_predit ))) {
90+ p <- p +
91+ ggplot2 :: geom_line(chart :: f_aes(y_predit ~ x ), color = " red" , data = data )
92+ }
93+ p
8894 })
8995
9096 trackEvents(session , input , output ,
9197 sign_in.fun = BioDataScience :: sign_in , config = conf )
92- trackSubmit(session , input , output , max_score = 2 , solution =
98+ trackSubmit(session , input , output , max_score = 3 , solution =
9399 list (asym = asym_init , xmid = xmid_init , scal = scal_init ),
94100 comment = " y = asym/1+e(xmid-x/scal)" ,
95101 message.success = " Correct, c'est le meilleur modèle." ,
0 commit comments