[R] outer() problem

Ken Knoblauch ken.knoblauch at inserm.fr
Thu May 1 09:52:24 CEST 2014


Marc Girondot <marc_grt <at> yahoo.fr> writes:
>  > outer(0:1, 0:1, FUN=function(x, y) {1})
> Erreur dans outer(0:1, 0:1, FUN = function(x, y) { :
>    dims [produit 4] ne correspond pas à la longueur de l'objet [1]

Because whatever the dimensions of your 2 input vectors,
this function simply returns the value 1 and outer expects
to generate an output that has a value for each pair of x and
y values, not a single value for the whole  set of xy pairs.

Note the lines in the source where the error occurs

 robj <- FUN(X, Y, ...)
 dim(robj) <- c(dX, dY)

where dX and dY are the lengths of x and y, respectively
in your case;

> Thanks a lot
> 
> Marc
> 
-- 
Kenneth Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html



More information about the R-help mailing list