HONR 399
Project 8 (7 points)
due Tuesday, November 10, at 5:00 PM

If you consult with other students about the solutions of the problems contained in this project, please describe the nature of the consultation and the participation of each member on the solution.

Type ALL solutions into 1 file saved in Plain Text format. (The R program uses Plain Text format as the default. Plain Text format is also available in other programs, such as Microsoft Word, but you usually must choose "Save As" to select Plain Text format.) Please do not use Microsoft Word (.doc or .docx) format, Rich Text Format (.rtf), etc. The file name should match your name, for example JohnDoeProject8.txt. Include comments throughout the file as needed, including your name at the top of the file.

Objective: This project is all about making maps and using colors. As a bonus, if desired, students can make cartograms.
1. First download the files for the maps:

http://www.vdstech.com/mapdata/usstates.zip

http://www.vdstech.com/mapdata/world.zip

Please note where you save the files. If you just click on the files, they will probably end up in your Downloads folder. If (instead) you press-and-hold the Control key before clicking (and continue to hold it while you click), then you can use the "Save File As" option to decide where to save it.... Dr. Ward saved his files, for instance, to the Desktop. (That's why Dr. Ward's Desktop often looks so cluttered.) Make sure that the folders are unzipped and that they are named usstates and world respectively.

Next, inside R, run the following two lines of code, to load the maptools library:

install.packages("maptools") # we should only need this line of code one time on each computer

library(maptools) # we need this line of code every time we start R

Next, change your working directory in R to the same location where both your usstates folder and world folder are downloaded. It might be the Desktop, for instance. In R for Windows, use "Change Dir" under the File Menu. In R for Mac, use "Change Working Directory" under the Misc Menu.

In class, I distributed names of the states in sorted order. If you want to see the names of the states in order (and also to check that everything is installed OK), you can run the following two lines of code:

trythis <- readShapePoly("usstates/usa_st")
sort(trythis$STATE_NAME)

or for the world data, the following two lines of code:

trythis <- readShapePoly("world/world")
sort(trythis$CNTRY_NAME)

Load the map function by entering the code found here
(please do not worry about how the code was written; just trust that it works OK and let Dr. Ward know if there are problems):

MapFunction.txt

There are many examples posted below (see the link) about how to use the MakeAMap function:

MapExamples.txt


2., 3., 4., 5., 6., 7. Now design your own maps or cartograms.
The instructions for cartograms are given below. The instructions for maps were already given above.

You should change the colors based on some types of data. For instance, in the examples, we make some colors for the maps according to the results in the Presidential elections from 2008.

Be creative with the colors and the data that is plotted. We learned 10 ways to make colors in Project 4, so you might want to look back at Project 4 for examples.

You can work by yourself or with another student in the course.
You can seek advice from Dr. Ward anytime. Dr. Ward is always happy to help.

You might have to try something several times before you get it right.

Dr. Ward would be very happy to help you at any point.

Cartograms

First load the maptools library, unless you already did this above!

install.packages("maptools") # we should only need this line of code one time on each computer

library(maptools) # we need this line of code every time we start R

Now there are three possible things to do:

1. If you are on a Windows computer that you own (NOT in a Purdue ITaP lab):
windows.txt

2. If you are on a Mac computer from Purdue ITaP:
macitap.txt

3. If you are on a Mac computer that you own (NOT in a Purdue ITaP lab):
macstudent.txt

4. If you are on a Windows computer from Purdue ITaP, then go to a different computer (one of the three types above) and try again.
Now we can load the cartogram function by entering the code found here
(please do not worry about how the code was written; just trust that it works OK and let Dr. Ward know if there are problems):

CartogramFunction.txt

There are many examples posted below (see the link) about how to use the MakeACartogram function:

CartogramExamples.txt

If you are stuck at any point, please ask Dr. Ward for help. Dr. Ward is always happy to help.