On Sun, 23 Sep 2001, Erich Neuwirth wrote:
> i cannot cajole outer in doing what i want it to do.
>
> i hav a function only defined for scalars
> fun(n,k)
>
> and i want to do
>
> outer(1:5,1:5,function(x,y) fun(x,y))
> (i know this is written somewhat clumsy)
>
> to get an array with the values of fun
> to use it as an input for image
>
> this does not work since
> outer assumes then fun works on arrays elementwise.
>
> what is the easiest way of getting what i want?
>
> outer in some lisp like variants and in mathematica will work with the
> function argument being a
> scalar argument only function.
> r is different here.
Well, R is a vector language and expect functions to handle vector
arguments. In fact it has no scalars, so I guess you mean that it will
only accept vectors of length one. You'll need to use loops, implicitly
(via *apply) or explicitly. Probably best to do this inside f, and make
it conform to the R model.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._