One of the main functionalities of the package. It is an alternative to standard way we define matrices in R.

m(...)

Arguments

...

Single values, vectors, matrices and `|` as special symbol which breaks input on the rows.

Value

matrix with defines elements

Examples

# Typically, we define matrices like this: x <- matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), nrow=3, byrow=TRUE) x
#> [,1] [,2] [,3] #> [1,] 1 2 3 #> [2,] 4 5 6 #> [3,] 7 8 9
# However, this way of ceating matices seems to be # a little bit clunky. Using `matricks`, we can do # it in more staightforward way dividing our input # into rows by using special symbol `|` x <- m(1, 2, 3| 4, 5, 6| 7, 8, 9) x
#> [,1] [,2] [,3] #> [1,] 1 2 3 #> [2,] 4 5 6 #> [3,] 7 8 9
# Moreover, we can pass to the `m` function # whole sequences or even matrices. x <- m(1:5 | 6:10 | 11:15 ) x
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 1 2 3 4 5 #> [2,] 6 7 8 9 10 #> [3,] 11 12 13 14 15
# We can combine multiple matrices into one m(diag(3), diag(3) * 3| diag(3) * 3, diag(3) )
#> [,1] [,2] [,3] [,4] [,5] [,6] #> [1,] 1 0 0 3 0 0 #> [2,] 0 1 0 0 3 0 #> [3,] 0 0 1 0 0 3 #> [4,] 3 0 0 1 0 0 #> [5,] 0 3 0 0 1 0 #> [6,] 0 0 3 0 0 1