Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

set.submatrix

Store matrix inside another matrix


Description

This function returns a matrix which is a copy of matrix x into which the contents of matrix y have been inserted at the given row and column.

Usage

set.submatrix(x, y, row, col)

Arguments

x

a matrix

y

a matrix

row

an integer row number

col

an integer column number

Value

A matrix.

Note

If the argument x is not a numeric matrix, then the function presents an error message and stops. If the argument y is not a numeric matrix, then the function presents an error message and stops. If the argument row is not a positive integer, then the function presents an error message and stops. If the argument col is not a positive integer, then the function presents an error message and stops. If the target row range does not overlap with the row range of argument x, then the function presents an error message and stops. If the target col range does not overlap with the col range of argument x, then the function presents an error message and stops.

Author(s)

Frederick Novomestky fnovomes@poly.edu

Examples

x <- matrix( seq( 1, 16, 1 ), nrow=4, byrow=TRUE )
y <- matrix( seq( 1, 4, 1 ), nrow=2, byrow=TRUE )
z <- set.submatrix( x, y, 3, 3 )

matrixcalc

Collection of functions for matrix calculations

v1.0-3
GPL (>= 2)
Authors
Frederick Novomestky <fnovomes@poly.edu>
Initial release
2012-09-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.