Skip to content

Commit 8d8c08b

Browse files
app shiny for linear model
1 parent f53460a commit 8d8c08b

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

inst/shiny/linear_model/server.R

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
trees <- data.io::read("trees", package = "datasets", lang = "FR") %>.%
17+
dplyr::select(., -height)
18+
19+
output$trees_plot <- renderPlot({
20+
21+
chart::chart(trees, volume ~ diameter) +
22+
ggplot2::geom_point() +
23+
geom_abline(aes(slope = input$slope_ui, intercept = input$intercept_ui))
24+
})
25+
})

inst/shiny/linear_model/ui.R

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
library(shiny)
2+
3+
titlePanel_h4 <- function(title, windowTitle = title) {
4+
tagList(tags$head(tags$title(windowTitle)), h4(title))
5+
}
6+
7+
# Define UI for application that draws a histogram
8+
shinyUI(fluidPage(
9+
titlePanel_h4("Le modèle linéaire intuitif"),
10+
sidebarLayout(
11+
sidebarPanel(
12+
withMathJax(),
13+
p("Une droite suit l'équation mathématique suivant: $$ y = ax + b $$ "),
14+
numericInput(inputId = "slope_ui", label = "Valeur de la pente (a)",
15+
value = 0.00, min = -10.00, max = 10.00, step = 0.5),
16+
p("Valeur par défaut : 0 "),
17+
numericInput(inputId = "intercept_ui", label = "Valeur de l'ordonnée à l'origine (b)",
18+
value = 1.00, min = -10.00, max = 10.00, step = 0.5),
19+
p("Valeur par défaut : 1 ")
20+
),
21+
mainPanel(
22+
h4("Ajustez aux mieux la droite dans ce nuage de points"),
23+
p("Nous pouvons traduire cette formule pour notre cas concret $$Volume = pente \\times diametre \\ + \\ ordonnee \\ à \\ l \\ origine$$ "),
24+
plotOutput("trees_plot")
25+
)
26+
)
27+
))

0 commit comments

Comments
 (0)