[R] How this addition works?

baptiste auguie ba208 at exeter.ac.uk
Thu May 28 22:04:08 CEST 2009


recycling rule: repeat the shorter element as many times as necessary,

all.equal(1:2 + 1:10 , rep(1:2, length=10) + 1:10)
# TRUE

HTH,

baptiste

On 28 May 2009, at 22:00, 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.

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag




More information about the R-help mailing list