matrix {Matrix} R Documentation

Matrices

Description


matrix creates a matrix from the given set of values.

Usage

matrix(
    data = NULL,
    nrow = 1,
    ncol = 1,
    byrow = FALSE,
    dimnames = NULL,
    sparse = FALSE);

Arguments

data

an optional data vector (including a list or expression vector). Non-atomic classed R objects are coerced by as.vector and all attributes discarded.

nrow

the desired number of rows. [as integer]

ncol

the desired number of columns. [as integer]

byrow

logical. If FALSE (the default) the matrix Is filled by columns, otherwise the matrix Is filled by rows. [as boolean]

dimnames

A dimnames attribute For the matrix: NULL Or a list of length 2 giving the row And column names respectively. An empty list Is treated as NULL, And a list of length one as row names. The list can be named, And the list names will be used as names for the dimensions. [as string]

sparse

[as boolean]

Details

If one of nrow or ncol is not given, an attempt is made to infer it from the length of data and the other parameter. If neither is given, a one-column matrix is returned. If there are too few elements In data To fill the matrix, Then the elements In data are recycled. If data has length zero, NA Of an appropriate type Is used For atomic vectors (0 For raw vectors) And NULL For lists.

Authors

sciBASIC.NET

Value

this function returns data object of type GeneralMatrix.

clr value class

Examples


[Package Matrix version 5.0.1.2389 Index]