In this section we discuss how to transform vectors. That is easy enough, but you need a for-loop to do this. So the best strategy is to avoid it if possible. While on the subject of vector operation, let us recall the Euclidean distance of two vectors is a sum of component-wise squared differences. However we can write a function my.sort for practice.
R is notoriously slow in handling for loops.
Let me show you how it works by a couple of examples. Suppose you want to create y, a vector of column sums. 12 Review Problems Exercise 1. Write a function max3 which returns the maximum of the three given numbers. Show your source code.