Consider the following for loops in R. For each for loop, list the values (in
order) that the variable i takes on in the body of the loop. Briefly (in no
more than a few sentences) explain why.
a)
for(i in 1+2:3.4*5) { }
b)
for(i in dim(matrix(0, nr = 7, nc = 8))) { }
c)
for(i in rnorm(3)) { }
d)
for(i in iris[1:3,3]) { }
e)
for(j in c(1, 2, 3, 4, 5)) { }
f)
for(i in (function(x) x*x)(c(1, 2, 3))) { }
g)
for(i in NULL) { }
h)
for(i in strsplit(as.character(4*atan(1)),’’)
[[1]][1:10]) { }