APPM2720 Homework 4

This is short assignment to reinforce the class work on for loops for plotting parts of data sets.

Refer to the R script Week04/scripts Looping4_1.R . Review this R code (but you do need to submit any work) and answer the data challenge:

Repeat the line fitting from the Audi A4 example for the CO2 data and GDP per cap in the WorldBankCO2 data set. Specifically work with the log10 of both GDP.cap CO2.cap and fit a least squares line using lm to the full data and then to sections of the data set divided according to the log10 GDP.cap. Recall that the cut function is helpful for dividing up a set of values into groups.

Make a summary plot similar to the one from class for the AudiA4 example to show how the lines change for the different sections.

How many cuts do you suggest to best represent the relationship.