Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
状況はかなり単純です。A各要素の値が所定の関数によって与えられる n 行 m 列の行列を作成したいと考えていますf(i, j)。これを達成するための最もエレガントな方法は何ですか?
A
f(i, j)
使用できますouter:
outer
outer(1:3,1:3,function(i,j) i^2+j) [,1] [,2] [,3] [1,] 2 3 4 [2,] 5 6 7 [3,] 10 11 12