An `R`

package with a single function: the matrix assignment operator `%<-%`

.

What's simpler:

```
# let's create a correlation matrix!
M <- matrix(c(1, 0.2, -0.3, 0.4,
0.2, 1, 0.6, -0.4,
-0.3, 0.6, 1, 0.4,
0.4, -0.4, 0.4, 1),
nrow = 4,
ncol = 4,
byrow = TRUE)
```

or

```
# Showing off the lower triangular feature:
M %<-% " 1
0.2, 1
-0.3, 0.6, 1
0.4, -0.4, 0.4, 1"
```

I like the second better. Hence `Massign`

.

```
# Development version
devtools::install_github("vankesteren/Massign")
library(Massign)
# CRAN (release) version
install.packages("Massign")
library(Massign)
```

Constructing matrices for quick prototyping can be a nuisance, requiring the user to think about how to fill the matrix with values using the matrix() function. The %<-% operator solves that issue by allowing the user to construct matrices using code that shows the actual matrices.

`%<-%`

?R users may already be used to the other matrix operations like `%*%`

and `%^%`

(from `expm`

). I felt this was a logical choice in that context.

```
#' @examples
# Basic usage
M %<-% " 1, 0.2, -0.3, 0.4
0.2, 1, 0.6, -0.4
-0.3, 0.6, 1, 0.4
0.4, -0.4, 0.4, 1"
# Variables allowed!
phi <- 1.5
V %<-% "1, 1, 1
1, phi, phi^2
1, phi^2, phi^4"
# We can also assign to the right:
" 1
0.5, 1
-0.2, 0.2, 1" %->% S
# Complex matrices work too:
C %<-% " 1+2i, 2+1i, 3+4i
4+0.5i, 5+2i, 6+4i"
# And lastly, if you're a fan of LaTeX and one-liners:
L %<-% "1, 2, 3 \\ 4, 5, 6 \\ 7, 8, 9 \\ 10, 11, 12"
# (although this kind of defeats the WYSIWYG purpose of Massign)
```

Anyone who uses `R`

for prototyping with matrices. For example, generating data with `lavaan`

can be made easier using `Massign`

, or trying out different matrix operations.
**NB: Massign is not for programming**. Due to the way the assignment operator

`%<-%`

currently works, I do not guarantee it to work once environments become a little more difficult. That's the font Fira Code, where `<-`

is a ligature. Check it out!

vankesteren/Massign documentation built on Jan. 29, 2018, 5:17 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.