Mapping in R – Earthquake Data

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:

  1. We are going to import the data, which is in Excel, and although there are a number of blank rows (> any([]); a total of 320 (> sum([])), 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([]))
[1] TRUE
> sum([]))
[1] 320



I need to get this cleaned up right quick. Meaning, I need to identify and clear out the blank spaces (NA’s).

> colSums([]))
 EQ.. Date Time Location Latitude Longitude 
 80   0    0    0        80       0 Magnitude Tectonic.Setting 
 80         80        0 
> EQ.Data <- na.omit(EQ.Data)
> sum([]))
[1] 0

This little bit of code cleaned up all of our blank spaces and now we can proceed with mapping!




About dwmaasberg

Memories are physical connections between neurons. I think that is pretty cool!
This entry was posted in Earthquake Data, R, Statistics. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s