Language
R
- First appeared
- 1993
- Paradigm
- Functional, array-oriented
- Toolchain
- R 4.6.2
- Container image
r-base:4.6.2 (recommended packages removed)
R was built by statisticians for statistics, so almost everything this
site implements by hand is already one built-in call: mean(), median(),
var(), sd(), cor(), lm(), and kmeans() all come with base R. The
from-scratch versions avoid them and show the arithmetic instead. R’s
packages from CRAN are where most of its data science lives; this image
removes even the recommended packages that normally ship with R, leaving
only base R and its standard packages, such as stats and utils.
Quirks
- Arithmetic is vectorized:
x - mean(x)subtracts the mean from every element at once, with no loop. - Vectors are indexed from 1.
var()divides by n − 1, like the formulas on this site.
Concepts in R
- Cross-validation
- Decision tree
- Descriptive statistics
- k-means clustering
- k-nearest neighbors
- Linear regression
- Logistic regression
- Naive Bayes
- Principal component analysis
- Descriptive statistics (built-in)
- k-means clustering (built-in)
- Linear regression (built-in)
- Logistic regression (built-in)
- Principal component analysis (built-in)
Run the examples locally
You need Docker and Python 3. The harness builds the pinned container and runs every R example:
git clone https://github.com/qnixon/dswithx.git
cd dswithx
python3 harness/run_tests.py --language r