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'.
y for R including: (1) wrappers for the base matrix function that allows matrices to be created from character strings and lists (the former is especially useful for creating block matrices), (ii) better default printing of large matrices, and (iii) a number of convenience functions for users more familiar with other scientific languages like Julia, MATLAB/Octave, or Python.
The main function in this package is
mat, an extention to the built-in matrix function. Many convenience functions are also available, for example:
mat, but constructs a block matrix.
mat, but returns a data frame instead of a matrix.
argmin- find the position of the max/min in each row or column of a matrix
eye- construct an identity matrix
vcat- concatenate matrices
fill- fill a matrix or array with a particular value
flatten- flatten (i.e., collapse) a matrix or array to one dimension
inv- calculate the inverse of a square matrix
logspace- construct a vector of linearly-spaced/logarithmically-spaced elements
meshgrid- construct matrices for evaluating functions over rectangular 2-D grids (useful for contour plots)
zeros- construct a matrix or array of all ones/zeros
randn- construct a matrix or array of uniformly/normally distributed random numbers
resize- change the size and shape of a given matrix or array
size- extract the dimensions of a matrix or array.
falses- construct a matrix or array of all
ramify introduces a pretty print function called
pprint. This is a generic function. Ordinarily, matrices are printed completely on the screen which is not very helpful when the dimensions are large. Using the
pprint function, however, allows you to see a more efficient printed version of the matrix. For example,
> m <- randn(1000, 1000) # matrix filled with a million normal random deviates> pprint(m) # compare this output to `print(m)` and `head(m)`## [,1] [,2] [,3] ... [,1000]# [1,] 0.0385 -0.0620 -0.0930 ... 1.9295# [2,] -2.5014 0.3277 1.1657 ... -0.6824# [3,] -0.1308 -0.9673 0.6388 ... -0.2852# ... ... ... ... ... ...# [1000,] 0.4980 0.6902 1.4920 ... -2.7023
This can be useful for viewing large (numeric) data frames too:
> data(Boston, package = "MASS") # Boston housing data> pprint(Boston)# 506 by 14 matrix of doubles## crim zn indus ... medv# 1 0.0063 18.0000 2.3100 ... 24.0000# 2 0.0273 0.0000 7.0700 ... 21.6000# 3 0.0273 0.0000 7.0700 ... 34.7000# ... ... ... ... ... ...# 506 0.0474 0.0000 11.9300 ... 11.9000
This printing behavior was partially inspired by the
"tbl_df" class for data frames provided by the
You can install the latest stable release from CRAN:
The development version is hosted on GitHub at https://github.com/bgreenwell/ramify and can be downloaded using
# Assuming devtools is already installeddevtools::install_github("bgreenwell/ramify")
Bug reports should be submitted to https://github.com/bgreenwell/ramify/issues.
NEWS for ramify package
pprintis now much faster for large matrices and data frames.
mat.characteris now a few times faster for numeric matrices.
"mat"class in function documentation.
resizedid not work correctly for matrices.
statspackages to Depends.
"mat"class in favor of a generic
at_least2doption to many functions for base R compatibility.
triu, etc. for constructing triangular functions.
meshgridfor MATLAB and Python+NumPy compatibility.
"mat"class when extracting or replacing parts.
"mat"introduced for better printing of large matrices.