Language: R
Purpose: Classroom exercise — let students guess the number of sweets in a jar. This script calculates the mean, median, and removes outliers. It generates three plots in RStudio to visually illustrate key statistical concepts.
SweetSpot is an engaging classroom activity designed to introduce students to basic statistics and the power of collective intelligence ("wisdom of the crowd"). Using R and a simple in-class exercise, students will submit their guesses for how many sweets are in a jar, and the teacher will use this script to process and visualize the results.
- A transparent jar filled with sweets (any kind!)
- An online form to collect guesses
(Google Forms, Microsoft Forms, Framaforms, etc.) - RStudio displayed on screen in the classroom
- The
SWEETSPOT.R
script and aDATASTUDENTS.TXT
file to hold the collected responses
-
Students vote
Students submit their guesses via the online form. -
Data is transferred
The teacher copies the guesses from the form results into a simpleData.txt
file (one number per line). -
Run the R script
The teacher opens RStudio and runs the provided script. -
Visualize the results
The script produces three key graphs:- A log-scaled plot with labels for each guess
- A jittered dot plot showing the distribution of guesses
- A histogram with automatic outlier detection and annotations
-
Facilitate discussion
Use the visualizations to engage students in a conversation about:- Mean vs. median
- Outliers and their effect
- Crowd wisdom and data aggregation
- Real-world uses of such techniques in polling, forecasting, etc.
- Option A: Google colab interactive notebook
- Option B: R script
- Collect guesses and paste them (as one number per line) into
DATASTUDENTS.TXT
. - Open RStudio and run
SWEETCOUNT3.R
. - Plots will be displayed in the RStudio plot viewer.
- Discuss the results in class!
- Understand basic statistical concepts (mean, median, outliers)
- Visualize and interpret numerical data
- Learn about collective estimation and "wisdom of the crowd"
- Practice reproducible data science using R
MIT License — feel free to adapt and reuse in your own classrooms!
Thanks to Julien Grimaud for his patient discussions on the evolving field of AI and data science, and to Mae Bourgeois for stimulating my interest in R.
As always, my programming capabilities are largely supported by ChatGPT. 4.5 , DeepSeek R1 and the Amazingly fast Mistral. For once Claude wasn't in the party.
Suggestions and improvements are welcome — especially ideas for new plots or educational enhancements. Submit a pull request or open an issue!