[R] Applying a function of several variables to data

Kjetil Kjernsmo kjetil.kjernsmo at astro.uio.no
Wed Dec 1 15:17:14 CET 1999


Dear all,

After looking at several packages I decided I would use R for my thesis
work (we've even got a site license for S-plus), so I'm learning.

I have run into a problem, and nobody on the house has a solution, so I'm
wondering if anybody out there can help. 
I've got two functions of four variables, one outputs a scalar, the other
an array, and I want to be able to give an array as a parameter for any
(or none) of the variables, and get a multidimensional array of
corresponding dimensions out, with all combinations. In the case of two
variables it is easy to do with outer(), and I have looked if apply() 
could do this, but found only examples where there is a function of one
variable. Obviously, I could do it with a for-loop at some level, but
after reading so many bad things about for-loops, it itches in my
estheticle thinking about it... :-) Is there a nicer way to do this?

Best,

Kjetil
-- 
Kjetil Kjernsmo
Graduate astronomy-student                    Problems worthy of attack
University of Oslo, Norway            Prove their worth by hitting back
E-mail: kjetikj at astro.uio.no                                - Piet Hein
Homepage <URL:http://www.astro.uio.no/~kjetikj/>
Webmaster at skepsis.no 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list