 class='language-R'>print("Looping - Example 1.7")

growth.rates &lt;- numeric(8)
for (j in seq(2,9)) {
    growth.rates[j-1] &lt;- (austpop[9, j]-austpop[1, j])/austpop[1, j] }
growth.rates &lt;- data.frame(growth.rates)
row.names(growth.rates) &lt;- names(austpop[c(-1,-10)])
  # Note the use of row.names() to name the rows of the data frame
growth.rates

pause()
print("Avoiding Loops - Example 1.7b")

sapply(austpop[,-c(1,10)], function(x){(x[9]-x[1])/x[1]})

pause()
print("Plot - Example 1.8a")
attach(au