Skip to content

Commit 227a503

Browse files
committed
Shiny app on linear regression reworked (y = a + bx)
1 parent e11aebb commit 227a503

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- New version for the academic year 2024-2025.
44

5+
- The Shiny app for linear regression is reworked to match new convention y = a + bx.
6+
57
# BioDataScience2 2023.9.0
68

79
- Learnrs **B09La_db**, **B09Lb_mds** and **B10La_som** revised for 2023-2024.

inst/shiny/B01Sa_reglin/app.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
learnitdown::learnitdownShinyVersion("1.0.0")
1+
learnitdown::learnitdownShinyVersion("1.1.0")
22
conf <- BioDataScience::config()
33

44
library(shiny)
55
library(learnitdown)
66
library(BioDataScience2)
77

8-
a_init <- -1.5
9-
b_init <- 3.5
8+
a_init <- 3.5
9+
b_init <- -1.5
1010
error_sd <- 0.25
1111
set.seed(42)
1212

1313
reglin <- function(x, a, b)
14-
(a * x) + b
14+
a + (b * x)
1515

1616
model_data <- tibble::tibble(
1717
x = seq(0, 10, by = 0.25),
@@ -24,7 +24,7 @@ ui <- fluidPage(
2424
sidebarLayout(
2525
sidebarPanel(
2626
withMathJax(),
27-
p("$$y(x) = a \\ x + \\ b $$"),
27+
p("$$y(x) = a \\ + \\ b \\ x$$"),
2828
sliderInput("a", label = "a",
2929
value = 0, min = -5, max = 5, step = 0.5),
3030
sliderInput("b", label = "b",
@@ -61,7 +61,7 @@ server <- function(input, output, session) {
6161

6262
output$model_equation <- renderUI({
6363
withMathJax(
64-
sprintf("$$y(x) \\ = %.02f \\ x + \\ %.02f$$",
64+
sprintf("$$y(x) \\ = %.02f \\ + \\ %.02f \\ x$$",
6565
input$a, input$b))
6666
})
6767

@@ -84,8 +84,8 @@ server <- function(input, output, session) {
8484
sign_in.fun = BioDataScience::sign_in, conf = conf)
8585
trackSubmit(session, input, output, max_score = 2,
8686
solution = list(a = a_init, b = b_init),
87-
comment = "y = a.x + b",
88-
message.success = "Correct, c'est le meilleur modèle. a est la pente et b est l'ordonnée à l'origine de la droite.",
87+
comment = "y = a + b.x",
88+
message.success = "Correct, c'est le meilleur modèle. a est l'ordonnée à l'origine et b est la pente de la droite.",
8989
message.error = "Incorrect, un modèle mieux ajusté existe.")
9090
trackQuit(session, input, output, delay = 20)
9191
}

0 commit comments

Comments
 (0)