Contents
Statistical Analysis with R
Probability and Sampling Basics
Probability tells us how likely an event is. R has ready functions for common distributions.
- rnorm() creates random numbers that follow a normal curve.
- pnorm() gives the chance of a value being below a point.
- sample() picks random items from your data.
Always run set.seed() first, so you get the same random results each time. These tools help you understand chance and let you test ideas with simulated data.

Correlation Analysis
Correlation measures how closely two numbers move together. It ranges from minus one to plus one.
- A value near +1 means that when one number rises, the other rises too.
- A value near 0 means there is no straight-line link.
Remember this rule: correlation does not prove cause. Two things can move together without one causing the other.
Also draw a scatter plot, because a single correlation number can hide an unusual pattern.
round(cor(d$study_hours, d$math), 3) # 0.822
Introduction to Hypothesis Testing
A hypothesis test checks whether a result could be due to chance. You start with a null hypothesis, which says there is no difference.
The p-value tells you how surprising your data would be if the null were true. A small p-value, usually below 0.05, is evidence against it.
- Use a t-test to compare two averages.
- Use ANOVA to compare three or more averages.
A result can be statistically real but still very small, so also look at the size of the difference.

R for Data Science
Harini A








