[R] How this addition works?
Luc Villandre
villandl at dms.umontreal.ca
Thu May 28 22:07:59 CEST 2009
bogaso.christofer wrote:
> I have following addition :
>
>
>
>
>> 1:2 + 1:10
>>
>
> [1] 2 4 4 6 6 8 8 10 10 12
>
>
>
> I could not understand how R adding those two unequal vector? Any help?
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
Hi,
R recycles the shorter vector to yield:
1+1 = 2
2+2 = 4
3+1 = 4
4+2 = 6
5+1 = 6
6+2 = 8
and so on. Is this what you wanted to know?
Cheers,
--
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/
More information about the R-help
mailing list