[R] Outer with Three Vectors

Wolfgang Viechtbauer wviechtb at cyrus.psych.uiuc.edu
Fri Feb 27 03:26:32 CET 2004


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?


Wolfgang Viechtbauer

More information about the R-help mailing list