Social Media Research

02 R Data Analysis


Question

What is Vector recycling ?


Answer

Vector recycling is a concept in R where, if two vectors of unequal length are part auf an operation, the elements of the shorter vector repeat until they match the length of the longer vector.

> v1 = c(0,0,0,0)
> v2 = 1:2
> v2
> v1 + v2
[1] 1 2 1 2



Comments

Was ist der Unterschied zu Elementwise execution?


Element Wise execution sagt erstmal nur das eine Operation immer für jedes Element einzeln ausgeführt wird. Also wenn v=1:10 und v+2 dann wird 2 auf jedes Element von v addiert. Recycling beschäftigt sich mit Operationen die mehrere ungleich lange Vektoren beinhaltet (so verstehe ich das zumindest)