Skip to content

Instantly share code, notes, and snippets.

@hepplerj
Created November 8, 2019 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hepplerj/44dda3ec78d804f5b7b4a13905a7a7b7 to your computer and use it in GitHub Desktop.
Save hepplerj/44dda3ec78d804f5b7b4a13905a7a7b7 to your computer and use it in GitHub Desktop.
Checking points and filtering incorrect or unneeded data.
library(tidyverse)
library(maps)
library(mapdata)
data <- read_csv("~/Desktop/nplsuperfund.csv")
names(data) <- c("lat","lon","date")
# Filter down to USA extent to remove extraneous points
tidy <- data %>%
filter(lat < -67, lat > -125) %>%
filter(lon > 25, lon < 50)
# Basemap
usa <- map_data("usa")
# Check data with a plot
ggplot() +
geom_polygon(data = usa, aes(x=long, y = lat, group = group)) +
geom_point(data = tidy, aes(x = lat, y = lon), color = "red") +
coord_fixed(1.3)
write_csv(tidy, "tidy.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment