B.5 Size information, reshaping/replicating & cleaning
The following statements are used to provide information on the dimensions of matrices or the number of observations or variables in a dataset, to reshape or replicate matrices, and to drop rows or columns with missing data from a matrix or dataset.
Syntax | Arguments and performed function |
S = size(X); | S is a matrix of integers. The first entry of S is the number of rows of X and the second entry is the number of columns of X.
|
p = rows(X); | p is a matrix equal to the number of rows of X.
|
p = cols(X); | p is a matrix equal to the number of columns of X.
|
W = kron(X, Y); | W is a matrix obtained as the Kronecker product of X, and Y.
|
W = repmat(X, M, N); | W is a matrix obtained by replicating X, M times along the row dimension and N times along the column dimension.
|
W = reshape(X, M, N); | W isan MN matrix constructed by reading the entries of X, in a column-major order.
|
W = dropmissing(X); | W is a matrix constructed by reading the entries of X, row by row, but skipping any rows in X that contain at least one missing value. An error is produced if an empty matrix results from dropping the rows of X with missing values.
When the argument provided to dropmissing() is a dataset, then the function returns a dataset. Therefore, this function is also documented in Section B.13. see also dropif and keepif |