[R] Odp: Manual recycling of vectors?

Charilaos Skiadas cskiadas at gmail.com
Fri Oct 19 16:38:31 CEST 2007


On Oct 19, 2007, at 10:25 AM, Petr PIKAL wrote:

> E.g.
>
> mat<-cbind(x,y)
>
Ah, that's an interesting idea, though it assumes they are of the  
same mode (admittedly, in my example they are, I should have made up  
an example where one of them is a character vector).

> gives you desired recycling in matrix form or
>
> x*(y>0)
>
> if you know that y is longer than x and all number are bigger than 0.

I had tried something similar, namely x+0*y, but that only works if  
they are both numeric and further the length of y must be a multiple  
of length of x to avoid a warning.

> Regards
> Petr

Thanks,
Haris Skiadas
Department of Mathematics and Computer Science
Hanover College



More information about the R-help mailing list