9. Loops. We will often want to access all of the elements of a data frame or vector in a sequence. We can do this using a for
loop. The
basic syntax is given below for printing elements 1 through N in vector X
:for (i in 1:N){print(X[j])}
.
You are given a vector of simple returns, simple_returns
. Use a for
loop and the log
function to compute and
print the log returns.