🌾 Week 2: Descriptive Statistics and Central Tendency

Understanding Your Data Through Statistical Measures 📊

Welcome to Week 2! This week, we explore descriptive statistics and measures of central tendency - essential tools for summarizing and understanding data in agricultural research. Learn to calculate mean, median, mode, variance, and standard deviation using R!

📊 What You'll Learn This Week

📈 Mean (μ or x̄) - The arithmetic average: μ = Σx / n
📊 Median - The middle value when data is ordered
🎯 Mode - The most frequently occurring value
📏 Variance (σ²) - Average squared deviation from mean
📐 Standard Deviation (σ) - Square root of variance
🔍 Coefficient of Variation - Relative variability measure

🚀 Getting Started: Step-by-Step Guide

Step 1: Launch Week 2 Binder Environment 🌐

Click the "Launch Week 2" button above to start your R environment. This will take 2-5 minutes to load with all necessary packages for descriptive statistics.

Step 2: Navigate to Class Activity 📚

Once Binder loads, you'll see the Jupyter Notebook interface. In the left panel, you'll see:

Click on the class_activity folder to access this week's content.

Step 3: Open the Week 2 Lab Notebook 📖

Inside the class_activity folder, double-click on Week2_Descriptive_Statistics.ipynb to open the interactive lab notebook.

Step 4: Work with the Iris Dataset 🌸

This week we'll use the built-in iris dataset - no external files needed! The notebook will guide you through:

🎯 Interactive Learning Tools

Practice with Visual Statistics Tools

Use these interactive tools to understand statistical concepts better before working with R code:

💡 Tip: Use these tools to visualize concepts before applying them in your R notebook!

🧮 Key R Functions This Week

Summary Statistics

summary(data) # Comprehensive summary
mean(data$column) # Calculate mean
median(data$column) # Calculate median
var(data$column) # Calculate variance
sd(data$column) # Calculate standard deviation
quantile(data$column) # Calculate quantiles

Data Exploration

head(data) # First 6 rows
str(data) # Data structure
nrow(data) # Number of rows
ncol(data) # Number of columns

Custom Mode Function

Mode <- function(x) {
ux <- unique(x)
ux[which.max(tabulate(match(x, ux)))]
}

📝 Assignment 2: Central Tendency Analysis

Step 1: Access Assignment Folder 📋

From the main directory, click on the assignment folder to access Assignment 2.

Step 2: Open Assignment 2 Notebook 📄

Double-click on Assignment2.ipynb to open your assignment on descriptive statistics.

Assignment Overview (20 points total)

📊

Part 1: Mean, Median, Mode (7 points)

Calculate central tendency measures for LA data

📏

Part 2: Variance & Standard Deviation (5 points)

Analyze variability across different subgroups

📐

Part 3: Quantiles (1 point)

Interpret Q1 and Q3 values for datasets

✍️

Written Analysis (7 points)

Compare statistics and draw inferences

Step 3: Complete Your Analysis ✍️

The assignment uses the LA dataset to compare statistics between:

Look for hints in comments to guide your coding!

🌾 Why This Matters in Agriculture

🌱 Crop Yields - Compare mean yields across varieties
🌍 Soil Properties - Understand nutrient variability
🌧️ Weather Patterns - Analyze rainfall and temperature
🐛 Pest Populations - Track abundance changes
Quality Control - Monitor product consistency

Understanding Variability Helps You:

💾 Saving Your Work

⚠️ Important: Binder environments are temporary! Always save your work locally.

Download Your Notebook 📥

When you're done working, save your progress:

  1. Save your notebook: File → Save
  2. Download .ipynb file: File → Download
  3. Export HTML/PDF: File → Save and Export Notebook As → HTML

Continue Your Progress Later 🔄

To resume your work:

  1. Launch Binder again
  2. Click Upload button
  3. Upload your saved .ipynb file
  4. Continue where you left off!

📤 Submission Requirements

For Assignment 2, submit TWO files to UC Davis Canvas:

📄

HTML/PDF Report

Your completed assignment with all outputs and analysis

💾

.ipynb File

Your notebook code as backup

Due Date: Check Canvas for assignment deadline

🎯 Learning Objectives

By the end of this week, you will be able to:

Calculate and interpret mean, median, and mode
Understand when to use each measure of central tendency
Compute variance, standard deviation, and CV
Interpret measures of variability in context
Use quantiles to understand data distribution
Compare statistics across different subgroups

❓ Need Help?

📧 Contact Information

Mohammadreza Narimani
📧 mnarimani@ucdavis.edu
🏫 Department of Biological and Agricultural Engineering, UC Davis

🔧 Common Issues

📚 Additional Resources

🌟 Tips for Success

💡 Best Practices

⚡ Keyboard Shortcuts

Shift + Enter Run current cell and move to next
Ctrl + Enter Run current cell and stay in place
A Insert cell above
B Insert cell below
DD Delete current cell

🎉 Ready to Start?

Click the Binder badge below to launch Week 2!

Happy analyzing! 📊🌾