Re: [R] Using sapply on a two argument function

2010-02-11 Thread Steven Worthington
Thanks Peter, your solution worked perfectly. It also helped me realize the mistake I made in my own script - the 'k' function was returning values for 'y' between 1:10 rather than .1:1 - it should have looked like this: k <- function(s) { n <- seq(.1, s/10, .1) m

Re: [R] Using sapply on a two argument function

2010-02-11 Thread Peter Ehlers
How about t(outer(seq(.1,1,.1), 1:12, foo)) Convert to dataframe, etc. -Peter Ehlers Steven Worthington wrote: Dear R users, I have a function (simplified here) that accepts two arguments and performs various calculations: foo <- function(y, x) { a <- y*sqrt(x)

[R] Using sapply on a two argument function

2010-02-11 Thread Steven Worthington
Dear R users, I have a function (simplified here) that accepts two arguments and performs various calculations: foo <- function(y, x) { a <- y*sqrt(x) b <- a+2 c <- a*b return(c) } If I call the function as follows I get th