2025-05-02

Introduction

This Shiny application predicts Sepal Width based on Sepal Length using a linear model trained on the built-in iris dataset.

It’s designed to be simple and beginner-friendly β€” ideal for users who want to understand how linear regression works in practice.

How It Works

  • Input: A slider lets users choose a Sepal Length value (range 4–8 cm).
  • The server uses a linear regression model:
lm(Sepal.Width ~ Sepal.Length, data = iris)
  • Output:
    • Text displaying the predicted Sepal Width
    • A plot of all Sepal Length vs Sepal Width with a regression line
    • A red dot indicating the prediction based on user input

Embedded Sample Code

This returns the expected Sepal Width when Sepal Length is 6.3 cm, based on the model.

Demo & Source Code