“If you want to learn to think you need a dialogue”
Immanuel Kant, 1786
September 10, 2025
“If you want to learn to think you need a dialogue”
Immanuel Kant, 1786
Bit of publicity for our book…
[1] 5
[1] 3
Error in sqrt("Peter"): non-numeric argument to mathematical function
function(argument1 = value1, argument2 = value2, ...)
Example: the function round, the first argument are the numbers you want to round, and the second argument the decimals you would like to retain (see lab!)
[1] 4.35
80/20 Rule: 102 functions likely handle 80% of common R tasks
Learning Priority: Master these functions before exploring specialized packages
Categories Matter: Functions cluster into logical groups for systematic learning
Data Structure (10 functions): Foundation for all R work
Statistics (10 functions): Core analytical capabilities
Data Transformation (8 functions): Essential for data wrangling
Visualization (8 functions): Critical for exploratory analysis
| Function | Purpose |
|---|---|
| c() | Combine values |
| data.frame() | Create data frame |
| list() | Create list |
| matrix() | Create matrix |
| array() | Create array |
| head() | Show first rows |
| tail() | Show last rows |
| str() | Display structure |
| summary() | Summary statistics |
| class() | Get object class |
| Category | Function | Description |
|---|---|---|
| Statistics | mean() | Calculate mean |
| Statistics | median() | Calculate median |
| Statistics | sd() | Standard deviation |
| Statistics | min() | Find minimum |
| Statistics | max() | Find maximum |
| Mathematics | abs() | Absolute value |
| Mathematics | sqrt() | Square root |
| Mathematics | exp() | Exponential |
| Mathematics | log() | Natural logarithm |
| Mathematics | round() | Round numbers |
| Category | Function | Usage |
|---|---|---|
| Base Plotting | plot() | Scatter plots |
| Base Plotting | hist() | Histograms |
| Base Plotting | boxplot() | Box plots |
| Base Plotting | barplot() | Bar charts |
| Statistical Modeling | lm() | Linear models |
| Statistical Modeling | glm() | Generalized linear models |
| Statistical Modeling | t.test() | T-tests |