DaveM2430 commited on
Commit
51b941a
Β·
verified Β·
1 Parent(s): 351759b

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +70 -47
app.R CHANGED
@@ -1,58 +1,81 @@
1
  library(shiny)
2
  library(bslib)
3
- library(dplyr)
4
- library(ggplot2)
5
-
6
- df <- readr::read_csv("penguins.csv")
7
- # Find subset of columns that are suitable for scatter plot
8
- df_num <- df |> select(where(is.numeric), -Year)
9
-
10
- ui <- page_sidebar(
11
- theme = bs_theme(bootswatch = "minty"),
12
- title = "Penguins explorer",
13
- sidebar = sidebar(
14
- varSelectInput("xvar", "X variable", df_num, selected = "Bill Length (mm)"),
15
- varSelectInput("yvar", "Y variable", df_num, selected = "Bill Depth (mm)"),
16
- checkboxGroupInput("species", "Filter by species",
17
- choices = unique(df$Species), selected = unique(df$Species)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  ),
19
- hr(), # Add a horizontal rule
20
- checkboxInput("by_species", "Show species", TRUE),
21
- checkboxInput("show_margins", "Show marginal plots", TRUE),
22
- checkboxInput("smooth", "Add smoother"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ),
24
- plotOutput("scatter")
 
 
 
 
 
 
25
  )
26
 
27
  server <- function(input, output, session) {
28
- subsetted <- reactive({
29
- req(input$species)
30
- df |> filter(Species %in% input$species)
31
  })
32
-
33
- output$scatter <- renderPlot(
34
- {
35
- p <- ggplot(subsetted(), aes(!!input$xvar, !!input$yvar)) +
36
- theme_light() +
37
- list(
38
- theme(legend.position = "bottom"),
39
- if (input$by_species) aes(color = Species),
40
- geom_point(),
41
- if (input$smooth) geom_smooth()
42
- )
43
-
44
- if (input$show_margins) {
45
- margin_type <- if (input$by_species) "density" else "histogram"
46
- p <- p |> ggExtra::ggMarginal(
47
- type = margin_type, margins = "both",
48
- size = 8, groupColour = input$by_species, groupFill = input$by_species
49
- )
50
- }
51
-
52
- p
53
- },
54
- res = 100
55
- )
56
  }
57
 
58
  shinyApp(ui, server)
 
1
  library(shiny)
2
  library(bslib)
3
+
4
+ ui <- page_fluid(
5
+ theme = bs_theme(
6
+ bg = "#ffffff",
7
+ fg = "#002147",
8
+ primary = "#002147",
9
+ base_font = font_google("Inter")
10
+ ),
11
+
12
+ # ── Header ──────────────────────────────────────────────────────────────────
13
+ div(
14
+ style = "background-color:#002147; padding:14px 24px;
15
+ display:flex; align-items:center; justify-content:space-between;
16
+ margin-bottom:20px;",
17
+ div(
18
+ tags$h1("CAPS", style="color:white; margin:0; font-size:26px; font-weight:700;"),
19
+ tags$p("Cape Cod Baseball League Analytics",
20
+ style="color:#aabbcc; margin:0; font-size:13px;")
21
+ ),
22
+ tags$img(
23
+ src = "https://upload.wikimedia.org/wikipedia/en/thumb/5/5f/Cape_Cod_Baseball_League_logo.svg/200px-Cape_Cod_Baseball_League_logo.svg.png",
24
+ height = "52px"
25
+ )
26
+ ),
27
+
28
+ # ── Filters ─────────────────────────────────────────────────────────────────
29
+ div(
30
+ style = "display:flex; gap:24px; align-items:flex-end;
31
+ padding:0 8px 20px 8px; flex-wrap:wrap;",
32
+
33
+ div(
34
+ style = "min-width:160px;",
35
+ tags$label("Level", style="font-weight:600; font-size:12px;
36
+ text-transform:uppercase; letter-spacing:0.4px;
37
+ color:#555; display:block; margin-bottom:4px;"),
38
+ selectInput("level", label=NULL,
39
+ choices = c("All","D1","D2","D3","JUCO","Other"),
40
+ selected = "All",
41
+ width = "100%")
42
  ),
43
+
44
+ div(
45
+ style = "min-width:160px;",
46
+ tags$label("Position", style="font-weight:600; font-size:12px;
47
+ text-transform:uppercase; letter-spacing:0.4px;
48
+ color:#555; display:block; margin-bottom:4px;"),
49
+ selectInput("position", label=NULL,
50
+ choices = c("Pitcher","Hitter"),
51
+ selected = "Pitcher",
52
+ width = "100%")
53
+ ),
54
+
55
+ div(
56
+ style = "min-width:160px;",
57
+ tags$label("Min Pitches", style="font-weight:600; font-size:12px;
58
+ text-transform:uppercase; letter-spacing:0.4px;
59
+ color:#555; display:block; margin-bottom:4px;"),
60
+ numericInput("min_pitches", label=NULL,
61
+ value=100, min=1, max=1000, step=25,
62
+ width="100%")
63
+ )
64
  ),
65
+
66
+ # ── Main content placeholder ─────────────────────────────────────────────────
67
+ div(
68
+ id = "main_content",
69
+ style = "padding:0 8px;",
70
+ uiOutput("main_ui")
71
+ )
72
  )
73
 
74
  server <- function(input, output, session) {
75
+ output$main_ui <- renderUI({
76
+ div(style="color:#888; font-size:14px; padding:20px;",
77
+ "Content will load here.")
78
  })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
 
81
  shinyApp(ui, server)