1. Start a new Rmd document by going to File-->New File-->R Markdown--OK. Save this document under the name yourname_hw4.Rmd.

  2. Delete the template Rmarkdown text and chunks (everything starting with ##R Markdown).

  3. Make a new code chunk (CTRL+Alt+I on Windows, Cmd + Option + I on a Mac). In that chuck, enter the code to load the classdata library and the terr_attacks data.

  4. The two graphs below show the average (mean) number of global terrorist attacks by target’s regime type (democracy/autocracy) and attack type. If you wanted to answer the question, “What attack types happen with roughly the same frequency irrespective of regime type?”, which of the graphs makes it easier? Explain why.

  1. In a new chunk, use the skills you learned in class to recreate the two graphs. Replicate all the options exactly.

  2. In yet another chunk, aggregate the data to show the average number of attacks by attack type and regime type in each year. Make a bar graph that shows year on the x-axis, the average number of attacks on the y-axis. Use the fill mapping to show regime type, and facets to show the type of attack.

  3. Describe the temporal patters in terrorist attacks overall and by regime type.

  4. Knit the RMarkdown file (press the “Knit” button above) and read through the corresponding html file.

Note:

This homework is supposed to be mainly a code reading exercise. You should not have to program extensively. Instead, you have to figure out which pieces you need to copy and adjust.

For the submission: submit your solution in an R Markdown file and (just for insurance) submit the corresponding html file with it.