[R] How this addition works?

Rolf Turner r.turner at auckland.ac.nz
Thu May 28 22:02:49 CEST 2009


On 29/05/2009, at 8:00 AM, 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?

Look at the help for ``+'' (?"+") and look at ``Value''.  There you will
see:

> These operators return vectors containing the result of the
> element by element operations.  The elements of shorter vectors
> are recycled as necessary (with a 'warning' when they are recycled
> only _fractionally_).  The operators are '+' for addition, '-' for
> subtraction, '*' for multiplication, '/' for division and '^' for
> exponentiation.

The key word is ``recycled''.

	cheers,

		Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}




More information about the R-help mailing list