https://github.com/krzjoa/matricks
Useful tricks for matrix manipulation.
https://github.com/krzjoa/matricks
algebra matrix matrix-manipulation r
Last synced: 3 months ago
JSON representation
Useful tricks for matrix manipulation.
- Host: GitHub
- URL: https://github.com/krzjoa/matricks
- Owner: krzjoa
- License: other
- Created: 2019-11-20T22:02:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-03T22:15:16.000Z (over 5 years ago)
- Last Synced: 2025-03-30T02:51:11.275Z (4 months ago)
- Topics: algebra, matrix, matrix-manipulation, r
- Language: R
- Homepage: https://krzjoa.github.io/matricks/
- Size: 1.71 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# matricks
![]()
> Useful tricks for matrix manipulation[](https://CRAN.R-project.org/package=matricks)
[](http://krzjoa.github.io/matricks)
[](https://travis-ci.org/krzjoa/matricks)
[](https://ci.appveyor.com/project/krzjoa/matricks)
[](https://www.redbubble.com/people/krzjoa/works/43111073-matricks-r-package-hex?asc=u&kind=sticker&p=sticker&size=small)### Installation
`matricks` is available on CRAN, so you can install it using simply:
```{r,message=FALSE, results='hide', eval=FALSE}
install.packages('matricks')
```
If you rather want to install dev version, you can do it with `devtools`.
```{r install.dev, message=FALSE, results='hide', eval=FALSE}
devtools::install_github('krzjoa/matricks')
```### Usage
Main `matricks` functions are `m` and `v`, which provide convenient API to create matrices and vectors.
Why should we write:
```{r matrix_function}
matrix(c(5, 6, 7,
8, 0, 9,
3, 7, 1), nrow = 3, byrow = TRUE)
```
if we can simply create such a matrix like that:
```{r m_function}
library(matricks)m(5, 6, 7|
8, 0, 9|
3, 7, 1)
````v` function is an useful shortcut for creating vertical vectors (single columns)
```{r v_function}
v(1,2,3)
v(1:5)
```Setting values in easier with `matricks`
```{r set_values_function}
mat <- matrix(0, 3, 3)
set_values(mat, c(1, 2) ~ 0.5, c(3, 1) ~ 7)
```