Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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