Choropleths |
Make a choropleth with data of your own choosing. Record the sequence of R commands used to prepare the map(s), and submit a text file containing those commands, plus the source of the dataset, so that your analysis is reproducible. Electronic submission is acceptible: submit the maps as a pdf and the R script as text files. To save a pdf, use
dev.copy(pdf,"mymap.pdf") dev.off()You MUST use dev.off() to close the pdf file properly.
Suggestions for datasets:
FL <- read.csv("http://www.reed.edu/~jones/141/FL.dat")
Notes: FIPS codes: Federal Information Processing Standards Some files record as character strings, some as numeric some as two fields, two digits for state, 3 digits for county, and some concatenate the 5 digits into a single field. For example: 41051 is Oregon (41), Multnomah County (051)
It will be easier to load your data into R if you have it stored in a csv file. If you have it in a spreadsheet or system file for another statistical package, use the export menu to save as a csv file. You may want to export only those columns you need for the map.
If you have a csv file on your desktop named Data.csv, you can load it into your R workspace with
Data <- read.csv("~/Desktop/Data.csv", as.is=TRUE)If you will be matching by name, make sure you have the format for the map names! Note that the world map is "a little" out of date. Searching on google turns up links to methods of getting a current map database, but it looks like a bit of a project. Anyone who is interested may substitute that project for the assignment!
Examples
> map("county",region="Oregon",plot=FALSE)$names [1] "oregon,baker" "oregon,benton""oregon,clackamas" "oregon,clatsop" [5] "oregon,columbia" "oregon,coos" "oregon,crook" "oregon,curry" <......etc.....>
> map("state",plot=FALSE)$names [1] "alabama" "arizona" [3] "arkansas" "california" [5] "colorado" "connecticut" [7] "delaware" "district of columbia" <......etc.....>
> map("world",plot=FALSE)$names[1:10] [1] "Canada" "South Africa" [3] "Denmark" "Great Lakes:Superior, Huron, Michigan" [5] "USSR" "Pakistan" <......etc.....>