2025-11-18

Slide 1: Introduction

  • This Shiny app allows users to interactively build linear models.
  • It uses the trees dataset (Girth vs Volume).
  • Users can brush points on the plot to select data for modeling.

Slide 2: How It Works

  • UI:
    • Displays slope and intercept.
    • Shows a plot with brushing enabled.
  • Server:
    • Reactively builds a model from brushed points.
    • If fewer than 2 points are selected, no model is created.

Slide 3: Visualization with Smoothing

  • library:
    • Uses ggplot2 for better visuals: refer to server.R file
  • functions used:
    • geom_point() for data points.
    • geom_smooth(method = “lm”) for regression line. Brushed points are highlighted in red. Confidence interval is shown around the regression line.

Slide 4: Outputs

  • Features of the app:
    • Slope and Intercept displayed in sidebar.
    • Plot updates dynamically:
    • Original data in black.
    • Brushed points in red.
    • Regression line in blue with confidence interval.

Slide 5: Reactive Model

```r model <- reactive({ brushed_data <- brushedPoints(trees, input$brush1, xvar = “Girth”, yvar = “Volume”) if(nrow(brushed_data) < 2) return(NULL) lm(Volume ~ Girth, data = brushed_data) })