On Apr 30, 2014, at 11:44 PM, Marc Girondot wrote:

> Dear list-members,
> 
> Can someone explains me why the last command gives an error. Thanks a lot:
> > outer(0:1, 0:1, FUN=function(x, y) {x+y})
>     [,1] [,2]
> [1,]    0    1
> [2,]    1    2
> > outer(0:1, 0:1, FUN=function(x, y) {x})
>     [,1] [,2]
> [1,]    0    0
> [2,]    1    1
> > 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]
> 
> Of course I simplify a lot my problem.

Try using rep() to get a vector of the correct length:

> outer(0:1, 0:1, FUN=function(x, y) {rep(1, length(x))})
     [,1] [,2]
[1,]    1    1
[2,]    1    1



> 
> Thanks a lot
> 
> Marc
> 
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to