0

I have a large eBird dataset for the midwest region of the US and want to narrow the data to focus on data within a certain set of longitudinal and latitudinal coordinates around the Mississippi River region. I have selected the geographic points I want to limit the data to but am not sure how to right the code to select the data I want.

Packages I am using: "auk", "tidyverse", "lubridate", "cowplot", "dplyr"

https://i.stack.imgur.com/O5pYD.png

Here is a screenshot of how the data is arranged. The bottom left corner of the image shows the size of the data set at the moment.

Ben G.
  • 35
  • 4
  • Hi Ben, can you please share a reproducible example (reprex) of your data? It can help others figure out the best way to solve your particular problem. Off-the-cuff, if your data is in a rectangular format, then you should be able to easily select your coordinates using `filter()` from the `dplyr` package – Adam B. Mar 27 '20 at 21:28
  • Hi Adam, Sorry for a probably very simple question, but what format would this example be best shared in? A screenshot of part of the data that I am working with? Or another format I am not familiar with as a beginner with this website and R in general? – Ben G. Mar 27 '20 at 21:31
  • 2
    BenG, some references for making a "reproducible question": https://stackoverflow.com/questions/5963269, [mcve], and https://stackoverflow.com/tags/r/info. Long story short: something like `dput(head(x))` might be enough, as well as whatever code you have tried (including listing non-base packages). – r2evans Mar 27 '20 at 21:35
  • 1
    @BenG. this is advice on how to make a great R reproductible example https://stackoverflow.com/a/5963610/3713478 – nurandi Mar 27 '20 at 21:36
  • The best thing would be if you could write a a short, ~3-5 line script to generate a fake version of your dataframe (using functions such as `sample()` and `rnorm()`) that mimics the relevant features of your data. Otherwise, a screenshot is fine too, some people here might give you hard time for posting screenshots but I think that's often just snobism (when it comes to beginner problems anyway). – Adam B. Mar 27 '20 at 21:37

1 Answers1

0

Let's say you're only interested in the latitudes 38-40 and longitudes -91 - -93 (no idea whether that actually makes sense with your data). Here's how you can select only the latitudes & longitudes you want:

library(tidyverse)

df %>%
   filter(latitude > 38 & latitude < 40 & longitude > -93 & longitude < -91)

Adam B.
  • 788
  • 5
  • 14