Additional matrix functionality for R including: (1) wrappers for the base matrix function that allow matrices to be created from character strings and lists (the former is especially useful for creating block matrices), (2) better printing of large matrices via the generic "pretty" print function, and (3) a number of convenience functions for users more familiar with other scientific languages like 'Julia', 'Matlab'/'Octave', or 'Python'+'NumPy'.
ramify is an R package that provides additional matrix functionality. Its goal is to make matrix creation and manipulation more convenient, especially for users familiar with scientific languages like MATLAB, Octave, or Python with NumPy.
mat(), which is useful for seeing the structure of the matrix in your code.bmat().pprint().eye(), ones(), zeros(), linspace(), meshgrid(), repmat(), and more.You can install the stable release from CRAN:
install.packages("ramify")
Or, you can install the development version from GitHub:
#install.packages("remotes")
remotes::install_github("bgreenwell/ramify")
library(ramify)
# Create a 2x3 matrix from a string.
mat("1, 2, 3; 4, 5, 6")
#> [,1] [,2] [,3]
#> [1,] 1 2 3
#> [2,] 4 5 6
# Use spaces as a separator instead of commas.
mat("1 2 3; 4 5 6", sep = "")
#> [,1] [,2] [,3]
#> [1,] 1 2 3
#> [2,] 4 5 6
# Create a 3x3 identity matrix.
eye(3)
#> [,1] [,2] [,3]
#> [1,] 1 0 0
#> [2,] 0 1 0
#> [3,] 0 0 1
# Create a 2x4 matrix of ones.
ones(2, 4)
#> [,1] [,2] [,3] [,4]
#> [1,] 1 1 1 1
#> [2,] 1 1 1 1
# "Pretty" printing large matrices
pprint(randn(100, 100))
#> 100 x 100 matrix of doubles:
#>
#> [,1] [,2] [,3] ... [,100]
#> [1,] -0.0918915 -1.6535266 1.9916211 ... 0.2545715
#> [2,] -1.3707209 0.8595378 1.6227581 ... 0.3485438
#> [3,] 0.3271210 -0.4506809 2.3066801 ... -0.2320033
#> ... ... ... ... ... ...
#> [100,] 0.3407804 1.3619685 0.4093369 ... -0.3140292
If you find a bug or have a feature request, please submit an issue on GitHub.
This package is licensed under the GPL-3.