How to map your data

 

  1. Download your data and load it into R
  2. Load map libraries:
    1. library(maps)
    2. library(maptools)
  3. Load the zip code data
    1. Set the working directory to where ever the zip code data is

                                                    i.     File -> Change Dir

    1. zip <- readShapePoly("zt06_d00_shp/zt06_d00")
  1. You may want to create a subset of your data that is just the chill or stress
    1. chill <- subset(stresschill,stress_value>0)
    2. How would you subset for stress?
    3. How would you handle “neutral” data (stress_value equals 0)?
  2. Draw your map of the county, zip code, etc.
    1. map('county','california,los angeles')
    2. plot(zip[zip$NAME=="90280",])
  3. Plot your points on the map
    1. points(chill$longitude,chill$latitude,col="blue")
    2. You can do a similar command to plot the stress in red
    3. You can use different characters as the points

                                                    i.     points(chill$longitude,chill$latitude,pch=20,col="blue")

                                                  ii.     points(chill$longitude,chill$latitude,pch="'",col="blue")

  1. Add a title
    1. title(“My Community”)