1 min read

The amaze of mapply()

Just learnt today that mapply(function(x, y), x, y) will pass element-by-element in BOTH x AND y variable.

mapply(function(x, y) x + y, x = c(1:3), y = c(10, 20, 30))
## [1] 11 22 33

That’s just amazing and got me realized the power of vectorization in R.