matrix_from_func | R Documentation |
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.
matrix_from_func(x, y, f, ...)
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. |
matrix whose elements are obtained from f with possible all combination of x and y
x=0:3
y=0:2
fn = function(x,y){return(x+y)}
matrix_from_func(x,y,fn)
#((0,1,2,3),(1,2,3,4),(2,3,4,5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.