search for: gouter

Displaying 4 results from an estimated 4 matches for "gouter".

Did you mean: router
2004 Feb 27
1
Outer with Three Vectors
Hello, outer() is great for avoiding things like: for (val1 in val1s) { for (val2 in val2s)) { x[i,j] <- somefunction(val1, val2) } } The same can be obtained with: outer(val1s, val2s, somefunction) But what if there are three (or more) sets of values to loop over? Any way of avoiding the loops then? Thanks, -- Wolfgang Viechtbauer
2005 Oct 31
1
[R] unvectorized option for outer()
...on "apply" would > emphasize the similarity to other flexible, not particularly > optimized > second-order functions. > > -thomas I'll toss in my $0.02: The following is my attempt at creating a "general outer" that works with more than two arguments. gouter <- function (x, FUN, ...) { xgrid <- as.list(do.call("expand.grid", x)) names(xgrid) <- NULL array(do.call(deparse(substitute(FUN)), c(xgrid, list(...))), dim = sapply(x, length), dimnames = x) } Here's an example: > example(gouter) gouter> gout...
2009 Feb 22
2
Semantics of sequences in R
...t of sequences? I understand that in long-running projects like S/R, there is an accumulation of contributions by a variety of authors, but perhaps the time has come for some cleanup at least for the base library? -s # generic outer: for generic vectors and non-vectorized functions gouter <- function(x,y,f,...) matrix( mapply( f, rep(x,length(y)), rep(y,each = length(x)), SIMPLIFY = FALSE ), # don't coerce booleans to numerics length(x), length(y), dimnames = list( names(x), names(y) ) ) # if arg e...
2009 Feb 22
2
Semantics of sequences in R
...t of sequences? I understand that in long-running projects like S/R, there is an accumulation of contributions by a variety of authors, but perhaps the time has come for some cleanup at least for the base library? -s # generic outer: for generic vectors and non-vectorized functions gouter <- function(x,y,f,...) matrix( mapply( f, rep(x,length(y)), rep(y,each = length(x)), SIMPLIFY = FALSE ), # don't coerce booleans to numerics length(x), length(y), dimnames = list( names(x), names(y) ) ) # if arg e...