matrix_from_func: Create matrix from function

View source: R/sequence.R

matrix_from_funcR Documentation

Create matrix from function

Description

This function create the matrix from a defined function and two sequences. The used function should support the sequence-style return from sequence-style arguments. Elements of the created matrix are obtained from the function with two arguments, which are possible combinations of elements from two sequences.

Usage

matrix_from_func(x, y, f, ...)

Arguments

x

First argument vectors, and length of x is the row of created matrix.

y

Second argument vectors, and length of y is the col of created matrix.

f

Function for creating matrix. This function should support the sequence-style return from sequence-style arguments.

...

Arguments are passed to function f.

Value

matrix whose elements are obtained from f with possible all combination of x and y

Examples

x=0:3
y=0:2
matrix_from_func(x,y,function(x,y){return(x+y)})
#((0,1,2,3),(1,2,3,4),(2,3,4,5))

hmito/hmRLib documentation built on March 13, 2024, 9:41 p.m.