[R] Problem applying "outer" to a list of functions

jschamel jtschamel at alaska.edu
Sat Oct 16 18:52:21 CEST 2010

I'm trying to construct an array with output from the application of
homogeneous input to a bunch of different functions (my final goal is to
easily analyze running time of a lot of competing functions and summarize
the results).  In my current iteration, however, only the first function in
the list is being applied, and I'm not sure why.  Here's my dummy code with

> foo <- function(x){paste('foo(',x,')',sep='')}
> bar <- function(x){paste('bar(',x,')',sep='')}
> outer(list(foo,bar),1:2,function(fl,x){fl[[1]](x)})
     [,1]     [,2]    
[1,] "foo(1)" "foo(2)"
[2,] "foo(1)" "foo(2)"

Any insight would be appreciated!  Thanks!
View this message in context: http://r.789695.n4.nabble.com/Problem-applying-outer-to-a-list-of-functions-tp2998406p2998406.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list