Learn R Programming

ramify (version 0.1.0)

bmat: Matrices

Description

Like mat, bmat creates a matrix from the given set of values. These values, however, must be represented by a character string.

Usage

bmat(x, rows = TRUE, sep = ",", ...)

Arguments

x
A data vector, character string, or a list.
rows
Logical. If TRUE (the default) the matrix is filled by rows, otherwise the matrix is filled by columns.
sep
Separator string. Values within each row/column of x are separated by this string. Default is ",".
...
Aditional optional arguments.

Details

Be careful when using R functions within character strings in the call to bmat. The character string is split according to ';' and then ','. For example, mat('rnorm(10)') will work, but mat('rnorm(10, mean = 3)') will result in an error. A work around would be to use mat('3 + rnorm(10, mean = 3)').

See Also

mat, dmat.

Examples

Run this code
# Construct a block matrix from matrices A1, A2, and A3
A1 <- mat('1, 1; 1, 1')
A2 <- mat('2, 2; 2, 2')
A3 <- mat('3, 3, 3, 3')
bmat('A1, A2; A3')

Run the code above in your browser using DataLab