matlib

Matrix Functions for Teaching and Learning Linear Algebra and Multivariate Statistics

https://github.com/friendly/matlib

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.3%) to scientific vocabulary

Keywords

diagrams linear-equations matrix matrix-functions matrix-visualizer vector vignette

Keywords from Contributors

package-creation
Last synced: 6 months ago · JSON representation

Repository

Matrix Functions for Teaching and Learning Linear Algebra and Multivariate Statistics

Basic Info
Statistics
  • Stars: 68
  • Watchers: 11
  • Forks: 16
  • Open Issues: 7
  • Releases: 11
Topics
diagrams linear-equations matrix matrix-functions matrix-visualizer vector vignette
Created over 10 years ago · Last pushed 10 months ago
Metadata Files
Readme Changelog

README.md

CRAN_Status_Badge R-universe Downloads downloads pkgdown <!-- Dependencies -->

matlib

Matrix Functions for Teaching and Learning Linear Algebra and Multivariate Statistics, http://friendly.github.io/matlib/

Version 1.0.1

These functions were originally designed for tutorial purposes in teaching & learning matrix algebra ideas using R. In some cases, functions are provided for concepts or computations available elsewhere in R, but where the name is not obvious, e.g., R() for the rank of a matrix, or tr() for matrix trace.

In other cases, we provide cover functions to show or demonstrate an algorithm in more detail, sometimes providing a verbose = argument to print the details of computations, e.g., Det() for a matrix determinant, Inverse() for a matrix inverse, using gaussianElimination() to show the steps.

In addition, a collection of functions are provided for drawing vector diagrams in 2D and 3D, illustrating various concepts of linear algebra more concretely than has been available before. For example,

  • showEqn(A, b) shows the matrix equations $\mathbf{A x} = \mathbf{b}$ in text or LaTeX form, while plotEqn(A, b) and plotEqn3d(A, b) plots those equations in 2D or 3D space.

  • matrix2latex(), latexMatrix(), Eqn() and friends facilitate writing matrix equations in LaTeX.

  • vectors(), vectors3d() plot geometric vector diagrams in 2D or 3D, with other functions to draw angles and arcs.

  • regvec3d() calculates and plot vectors representing a bivariate regression model, lm(y ~ x1 + x2)

Installation 📦

Get the released version from CRAN:

 install.packages("matlib")

Or the development version from my R-universe:

install.packages('matlib', repos = c('https://friendly.r-universe.dev', 'https://cloud.r-project.org'))

The development version can also be installed to your R library directly from this repo via:

 if (!require(remotes)) install.packages("remotes")
 remotes::install_github("friendly/matlib", build_vignettes = TRUE)

The functions that draw 3D graphs use the rgl package. On macOS, rgl requires that XQuartz be installed. After installing XQuartz, it's necessary either to log out of and back into your macOS account or to reboot your Mac.

Topics 🍪

The functions in this package are grouped under the following topics

  1. Convenience functions:
  • tr() - trace of a matrix
  • R() - rank of a matrix
  • J() - constant vector, matrix or array
  • len() - Euclidean length of a vector or columns of a matrix
  • vec() - vectorize a matrix
  • Proj(y, X) - projection of vector y on columns of matrix X
  • mpower(A, p) - matrix powers for a square symmetric matrix
  • xprod(...) - vector cross-product
  1. Determinants: functions for calculating determinants by cofactor expansion
  • minor() - Minor of A[i,j]
  • cofactor() - Cofactor of A[i,j]
  • rowMinors() - Row minors of A[i,]
  • rowCofactors() - Row cofactors of A[i,]
  • Det() - Determinants by elimination or eigenvalues
  1. Elementary row operations: functions for solving linear equations "manually" by the steps used in row echelon form and Gaussian elimination
  • rowadd() - Add multiples of rows to other rows
  • rowmult() - Multiply rows by constants
  • rowswap() - Interchange two rows of a matrix
  1. Linear equations: functions to illustrate linear equations of the form $\mathbf{A x = b}$
  • showEqn(A, b) - show matrices (A, b) as linear equations, as text or in LaTeX
  • plotEqn(A, b), plotEqn3d(A, b) - plot matrices (A, b) as linear equations
  1. Gaussian elimination: functions for illustrating Gaussian elimination for solving systems of linear equations of the form $\mathbf{A x = b}$. These functions provide a verbose=TRUE argument to show the intermediate steps and a fractions=TRUE argument to show results using MASS::fractions().
  • gaussianElimination(A, B) - reduces $(A, B)$ to $(I, A^{-1} B)$
  • Inverse(X), inv() - uses gaussianElimination to find the inverse of X, $\mathbf{X}^{-1}$
  • echelon(X) - uses gaussianElimination to find the reduced echelon form of X
  • Ginv(X) - uses gaussianElimination to find the generalized inverse of X
  • LU(X) - LU decomposition of a matrix X
  • cholesky(X) - calculates a Cholesky square root of a matrix
  • swp() - matrix sweep operator
  1. Eigenvalues: functions to illustrate the algorithms for calculating eigenvalues and eigenvectors and related matrix decompositions and generalizations.
  • Eigen() - eigenvalues and eigenvectors
  • SVD() - singular value decomposition, \$mathbf{X = U D V}$
  • powerMethod() - find the dominant eigenvector using the power method
  • showEig() - draw eigenvectors on a 2D scatterplot with a dataEllipse
  • MoorePenrose() - illustrates how the Moore-Penrose inverse can be calculated using SVD()
  1. Vector diagrams: functions for drawing vector diagrams in 2D and 3D
  • arrows3d() - draw nice 3D arrows
  • corner(), arc() - draw a corner or arc showing the angle between two vectors in 2D/3D
  • pointOnLine() - position of a point along a line
  • vectors(), vectors3d() - plot geometric vector diagrams in 2D/3D
  • regvec3d() - calculate and plot vectors representing a bivariate regression model, lm(y ~ x1 + x2) in mean-deviation form.
  1. Matrix equations in LaTeX
    • matrix2latex(): Convert matrix to LaTeX equation
    • latexMatrix(): Create and manipulate LaTeX representations of matrices
    • latexMatrixOperations: Matrix operators (e.g., %*%, %O%) and functions (matmult(), kronecker()) for matrix arithmetic, but rendered in LaTeX
    • Eqn(): A wrapper for equations composed from latexMatrix() expressions and LaTeX text, with ability to preview the results in a Viewer pane.

Vignettes and presentations

A small collection of vignettes is now available. Use browseVignettes("matlib") to explore them.

| Vignette | Title | |-------------------------------------------------------------------------------------------|----------------------------------------------- | | a1-det-ex1 | Properties of determinants | | a2-det-ex2 | Evaluation of determinants | | a3-inv-ex1 | Inverse of a matrix | | a4-inv-ex2 | Matrix inversion by elementary row operations | | a5-ginv | Generalized inverse | | a6-inv-3d | Linear transformations and matrix inverse in 3D | | a7-eigen-ex1 | Eigenvalues and Eigenvectors: Properties | | a8-eigen-ex2 | Eigenvalues: Spectral Decomposition | | a9-linear-equations | Solving Linear Equations | | aA-gramreg | Gram-Schmidt Orthogonalization and Regression | | aB-data-beta | Vector Spaces of Least Squares and Linear Equations | | latex-equations | LaTeX Equations with latexMatrix, Eqn and matrix2latex|

See also:

Owner

  • Name: Michael Friendly
  • Login: friendly
  • Kind: user
  • Location: Toronto
  • Company: York University

GitHub Events

Total
  • Issues event: 8
  • Watch event: 2
  • Issue comment event: 41
  • Push event: 28
Last Year
  • Issues event: 8
  • Watch event: 2
  • Issue comment event: 41
  • Push event: 28

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 781
  • Total Committers: 8
  • Avg Commits per committer: 97.625
  • Development Distribution Score (DDS): 0.392
Past Year
  • Commits: 389
  • Committers: 4
  • Avg Commits per committer: 97.25
  • Development Distribution Score (DDS): 0.54
Top Committers
Name Email Commits
Michael Friendly f****y@y****a 475
philchalmers r****s@g****m 172
John Fox j****x@m****a 129
l-d-s l@s****g 1
Jay Hesselberth j****h@g****m 1
Duncan Murdoch m****n@g****m 1
Douglas Whitaker d****g@1****t 1
John Fox J****x 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 57
  • Total pull requests: 14
  • Average time to close issues: 4 months
  • Average time to close pull requests: about 2 months
  • Total issue authors: 17
  • Total pull request authors: 6
  • Average comments per issue: 9.16
  • Average comments per pull request: 1.79
  • Merged pull requests: 14
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 20
  • Pull requests: 1
  • Average time to close issues: 14 days
  • Average time to close pull requests: about 19 hours
  • Issue authors: 3
  • Pull request authors: 1
  • Average comments per issue: 16.95
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • friendly (31)
  • john-d-fox (6)
  • philchalmers (5)
  • JanaJarecki (2)
  • silberc (1)
  • rjrovetti (1)
  • foyizzle (1)
  • ggrothendieck (1)
  • TengMCing (1)
  • aoandrade (1)
  • g-aruda (1)
  • gejak2004 (1)
  • dumbdrummer182 (1)
  • jefferis (1)
  • charlesjom (1)
Pull Request Authors
  • friendly (6)
  • philchalmers (4)
  • jayhesselberth (2)
  • l-d-s (1)
  • douglaswhitaker (1)
  • dmurdoch (1)
Top Labels
Issue Labels
enhancement (4)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • cran 2,608 last-month
  • Total docker downloads: 42,448
  • Total dependent packages: 12
    (may contain duplicates)
  • Total dependent repositories: 7
    (may contain duplicates)
  • Total versions: 20
  • Total maintainers: 1
cran.r-project.org: matlib

Matrix Functions for Teaching and Learning Linear Algebra and Multivariate Statistics

  • Versions: 16
  • Dependent Packages: 12
  • Dependent Repositories: 7
  • Downloads: 2,608 Last month
  • Docker Downloads: 42,448
Rankings
Forks count: 4.8%
Stargazers count: 5.5%
Downloads: 5.5%
Dependent packages count: 5.7%
Average: 10.0%
Dependent repos count: 11.1%
Docker downloads count: 27.3%
Maintainers (1)
Last synced: 7 months ago
conda-forge.org: r-matlib
  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 34.0%
Stargazers count: 35.3%
Forks count: 38.1%
Average: 39.7%
Dependent packages count: 51.2%
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • MASS * imports
  • car * imports
  • methods * imports
  • rgl * imports
  • xtable * imports
  • carData * suggests
  • knitr * suggests
  • markdown * suggests
  • rglwidget * suggests
  • rmarkdown * suggests
  • webshot2 * suggests
revdep/library/matlib/new/digest/DESCRIPTION cran
  • R >= 3.3.0 depends
  • utils * imports
  • knitr * suggests
  • minidown * suggests
  • rmarkdown * suggests
  • tinytest * suggests
revdep/library/matlib/new/matlib/DESCRIPTION cran
  • MASS * imports
  • car * imports
  • methods * imports
  • rgl * imports
  • xtable * imports
  • carData * suggests
  • knitr * suggests
  • rglwidget * suggests
  • rmarkdown * suggests
revdep/library/matlib/new/ps/DESCRIPTION cran
  • R >= 3.1 depends
  • utils * imports
  • R6 * suggests
  • callr * suggests
  • covr * suggests
  • curl * suggests
  • pingr * suggests
  • processx >= 3.1.0 suggests
  • rlang * suggests
  • testthat * suggests
  • tibble * suggests
revdep/library/matlib/old/matlib/DESCRIPTION cran
  • MASS * imports
  • car * imports
  • methods * imports
  • rgl * imports
  • xtable * imports
  • carData * suggests
  • knitr * suggests
  • rglwidget * suggests
  • rmarkdown * suggests
revdep/library/matlib/new/cli/DESCRIPTION cran
  • R >= 3.4 depends
  • utils * imports
  • callr * suggests
  • covr * suggests
  • digest * suggests
  • glue >= 1.6.0 suggests
  • grDevices * suggests
  • htmltools * suggests
  • htmlwidgets * suggests
  • knitr * suggests
  • methods * suggests
  • mockery * suggests
  • processx * suggests
  • ps >=1.3.4.9000 suggests
  • rlang >= 1.0.2.9003 suggests
  • rmarkdown * suggests
  • rprojroot * suggests
  • rstudioapi * suggests
  • testthat * suggests
  • tibble * suggests
  • whoami * suggests
  • withr * suggests
revdep/library/matlib/new/processx/DESCRIPTION cran
  • R >= 3.4.0 depends
  • R6 * imports
  • ps >= 1.2.0 imports
  • utils * imports
  • callr >= 3.7.0 suggests
  • cli >= 3.3.0 suggests
  • codetools * suggests
  • covr * suggests
  • curl * suggests
  • debugme * suggests
  • parallel * suggests
  • rlang >= 1.0.2 suggests
  • testthat >= 3.0.0 suggests
  • withr * suggests
revdep/library/matlib/new/vctrs/DESCRIPTION cran
  • R >= 3.3 depends
  • cli >= 3.4.0 imports
  • glue * imports
  • lifecycle >= 1.0.3 imports
  • rlang >= 1.0.6 imports
  • bit64 * suggests
  • covr * suggests
  • crayon * suggests
  • dplyr >= 0.8.5 suggests
  • generics * suggests
  • knitr * suggests
  • pillar >= 1.4.4 suggests
  • pkgdown >= 2.0.1 suggests
  • rmarkdown * suggests
  • testthat >=3.0.0 suggests
  • tibble >= 3.1.3 suggests
  • waldo >= 0.2.0 suggests
  • withr * suggests
  • xml2 * suggests
  • zeallot * suggests