search for: skalar

Displaying 1 result from an estimated 1 matches for "skalar".

Did you mean: scalar
2010 Nov 12
1
Xapply question
...t, but > A <- matrix (rnorm (12), 3) > A [,1] [,2] [,3] [,4] [1,] 0.1286 0.2888 -0.4435 -0.90966 [2,] -1.6000 -1.0884 1.3736 0.07754 [3,] 0.4581 1.5413 0.6133 -0.12131 > v <- 1 : 3 > f <- function (x, y) { # some function depending on vector x and skalar y + c (sum (x^2), y) + } > result <- matrix (NA, nrow = nrow (A), ncol = 2) > for (r in 1 : nrow (A)) + result [r,] <- f (A [r,], v [r]) > result [,1] [,2] [1,] 1.124 1 [2,] 5.637 2 [3,] 2.976 3 The matrix will easily be in the range of 1e4 - 1e5 rows x 1e2...