Skip to content
Prev 361087 / 398506 Next

Element-by-element operation (adding)

Or, as you're messing with transposes anyways, use the fact that the column-wise counterpart is automagically handled by recycling:

t(t(v)+b)

Or, look Ma, no transposes
 
v + rep(b, each=nrow(v))

(_always_ doublecheck the logic when you apply these and similar techniques! I have seen my share of student code where recycling had been applied along the wrong dimension of a matrix...)