R Matrix
An R Matrix is a matrix data structure that is an R array data structure.
- AKA: R Table, R Array.
- Context:
- It has an R dim Vector.
- It can have R Matrix Columns (with column names associated by colnames() of dimnames()).
- It can have R Matrix Rows (with row names associated by rownames() of dimnames()).
- It can be converted to an R Vector by removing the dim vector (
dim(mx) <- NULL
) or by concatenating its members into a new vector (vec <- c(matrix)
). - It can be shrunk with a command such as:
array<- array[-4:-6,-7:-9]
- Example(s):
x <- matrix(1:21, nrow=3, ncol=7, byrow = FALSE); colnames(x) <- paste('cname', 1:7); x[,'cname 2']
- Counter-Example(s):
- an R Vector.
- a Python Matrix, Scala Matrix, Perl Matrix, ...
- See: Tuple, R matrix() Function, R array() Function, R dim() Function.
References
2012
- http://cran.r-project.org/doc/manuals/R-intro.html#Arrays
- An array can be considered as a multiply subscripted collection of data entries, for example numeric. R allows simple facilities for creating and handling arrays, and in particular the special case of matrices.
A dimension vector is a vector of non-negative integers. If its length is k then the array is k-dimensional, e.g. a matrix is a 2-dimensional array. The dimensions are indexed from one up to the values given in the dimension vector.
A vector can be used by R as an array only if it has a dimension vector as its dim attribute. Suppose, for example, z is a vector of 1500 elements. The assignment
> dim(z) <- c(3,5,100)
gives it the dim attribute that allows it to be treated as a 3 by 5 by 100 array.
Other functions such as matrix() and array() are available for simpler and more natural looking assignments.
- An array can be considered as a multiply subscripted collection of data entries, for example numeric. R allows simple facilities for creating and handling arrays, and in particular the special case of matrices.