I have been messing around with the Pew Voter Data and have been unable to access the underlying Zip Codes from the data set in order to attach a latitude and longitude to each respondent and map their location and affiliations…
So… I found a data set from a project that I did my Junior year in college. A project that maps the locations of all seismic activity around the world for 6 months. Now, when I did this project, I used a large map of the world and a 3 foot ruler to map all activity with colors that corresponded to the size of the activity as measured by the richter scale. I have a feeling that writing a few lines of code are going to by much more simple:
- We are going to import the data, which is in Excel, and although there are a number of blank rows (> any(is.na(EQ.Data); a total of 320 (> sum(is.na(EQ.Data)), the data are well organized. And even better, me 12 years ago (!) detailed the Lat and Long out to 3 decimal places!
> EQ.Data <- read.csv("Desktop/Working Directory - R/Earth_Quake_Data.csv", header=TRUE) > View(EQ.Data) > any(is.na(EQ.Data))  TRUE > sum(is.na(EQ.Data))  320
I need to get this cleaned up right quick. Meaning, I need to identify and clear out the blank spaces (NA’s).
> colSums(is.na(EQ.Data)) EQ.. Date Time Location Latitude Longitude 80 0 0 0 80 0 Depth..km. Magnitude Tectonic.Setting 80 80 0 > EQ.Data <- na.omit(EQ.Data) > sum(is.na(EQ.Data))  0
This little bit of code cleaned up all of our blank spaces and now we can proceed with mapping!