This online appendix lists the R source files used to produce some of the figures and analyses in each chapter, with links to the source code on GitHub.
This is included here because it may be useful to readers to see the complete context in which many examples were developed, beyond the code displayed in the text. And also because you may want to use or adapt the code for your own work or to develop related examples using the same ideas with different datasets.
It is incomplete because it was consctructed by scanning the chapter source files for special comments, of the form <!-- fig.code: R/Davis-reg.R --> that were manually embedded in the chapter .qmd files as I wrote this, but not always. Making this less incomplete proved to be a challenge because it involved scanning the text to find the corresponding R code files that had been included that had been included in chunks.
Files marked ⚠ do not yet have a descriptive title in their header.
Chapter 3: Getting Started
- Davis-reg.R — Davis data– Models and plots
- draft1970.R — 1970 Draft Lottery
Chapter 4: Plots of Multivariate Data
- Salaries-scatterplots.R — Salaries data: scatterplots
- ellipses-coverage.R — demo ellipses of varying coverage
- prestige.R — Prestige data plots
- peng-ggplot.R — Penguins data, scatterplot matrix, data ellipses and 2D density plots
- geom-bagplot.R — geom_bagplot– penguin data
- peng-ggally.R — Penguin data, GGally ggpairs
- peng-ggpcp.R — Penguin data, parallel coordinate plots
Chapter 5: Dimension Reduction
- workers-pca.R — Workers data - pca
- crime-ggbiplot.R — crime data - ggbiplot
- ⚠
R/crime/factominer.R— file not found - diabetes-3d.R — Diabetes data, 3D plots
- ⚠ diabetes-ggbiplot.R — no title
- diabetes-mds.R — Diabetes data, multidimensional scaling (MDS)
- diabetes-pca-tsne.R — Animate transition from PCA <–> tsne
- mtcars-corrplot.R — Variable ordering based on PCA & corrplot
- outlier-demo.R — Demonstrate correlated data with 2 outliers
Chapter 6: Overview of Linear models
- workers-reg.R — Workers data - regression models
Chapter 7: Plots for Univariate Response Models
- dunc-conf-ellipse.R — Duncan data Confidence ellipse
- levdemo.R — Leverage and influence demo
- hatvalues-demo.R — leverage and the data ellipse
Chapter 8: Topics in Linear Models
- dual-points-lines.R — Illustrate dual points & lines
- measerr-demo.R — Simulation for measurement error
Chapter 9: Collinearity & Ridge Regression
- collin-data-beta.R — collinearity in data and beta space
- cars-colldiag.R — cars data - collinearity diagnostics examples
- collin-centering.R — demonstrate effect of centering
- acetylene-colldiag.R — Acetylene data
- genridge-longley-figs1.R — Longley data– generalized ridge trace plots
- genridge-longley-figs2.R — Longley data– generalized ridge trace plots
Chapter 10: Hotelling’s \(T^2\)
- mathscore-figs.R — mathscore data
- banknote.R — banknote data
Chapter 12: Visualizing Multivariate Models
- dogfood-quartet.R — dogfood quartet
Chapter 14: Multivariate Influence and Robust Estimation
- mvinfluence-Toy.R — toy example for multivariate influence
- peng-manova.R — Penguins MANOVA
Appendix: Discriminant analysis
- peng-lda-pred-new.R — Penguin prediction plots
- iris-lda-ggplot.R — plot LDA boundaries with ggplot
- peng.lda.R — Penguin data– lda plots
Rcode
- Davis-reg.R — Davis data– Models and plots
Utilities
These R files are source()d by one or more of the scripts above. They define custom functions and helpers used across multiple chapters.
- penguin-colors.R — penguin colors
- ggvectors.R — Draw labeled vectors in a ggplot scene
- text.usr.R — Add text to a plot at normalized device coordinates