Useful Tricks for Matrix Manipulation

Provides functions, which make matrix creation conciser (such as the core package's function m() for rowwise matrix definition or runifm() for random value matrices). Allows to set multiple matrix values at once, by using list of formulae. Provides additional matrix operators and dedicated plotting function.


matricks

Useful tricks for matrix manipulation

Documentation Travis buildstatus AppVeyor buildstatus Buy hexstciker

Installation

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:

matrix(c(5, 6, 7,
         8, 0, 9,
         3, 7, 1), nrow = 3, byrow = TRUE)
#>      [,1] [,2] [,3]
#> [1,]    5    6    7
#> [2,]    8    0    9
#> [3,]    3    7    1

if we can simply create such a matrix like that:

library(matricks)

m(5, 6, 7|
  8, 0, 9|
  3, 7, 1)
#>      [,1] [,2] [,3]
#> [1,]    5    6    7
#> [2,]    8    0    9
#> [3,]    3    7    1

v function is an useful shortcut for creating vertical vectors (single columns)

v(1,2,3)
#>      [,1]
#> [1,]    1
#> [2,]    2
#> [3,]    3
v(1:5)
#>      [,1]
#> [1,]    1
#> [2,]    2
#> [3,]    3
#> [4,]    4
#> [5,]    5

Setting values in easier with matricks

mat <- matrix(0, 3, 3)
set_values(mat, c(1, 2) ~ 0.5, c(3, 1) ~ 7)
#>      [,1] [,2] [,3]
#> [1,]    0  0.5    0
#> [2,]    0  0.0    0
#> [3,]    7  0.0    0

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("matricks")

0.8.2 by Krzysztof Joachimiak, 7 years ago


https://github.com/krzjoa/matricks, https://krzjoa.github.io/matricks/


Report a bug at https://github.com/krzjoa/matricks/issues


Browse source code at https://github.com/cran/matricks


Authors: Krzysztof Joachimiak [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports Rcpp, rlang, ggplot2, reshape2

Suggests testthat, knitr, rmarkdown, covr

Linking to Rcpp


See at CRAN