library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 0.3.5
## ✔ tibble 3.1.8 ✔ dplyr 1.0.10
## ✔ tidyr 1.2.1 ✔ stringr 1.5.0
## ✔ readr 2.1.3 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(dplyr)
library(readr)
MBT_ebird<- read_csv("https://github.com/mbtoomey/Biol_7263/blob/main/Data/MBT_ebird.csv?raw=true")
## New names:
## Rows: 6595 Columns: 14
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (4): list_ID, common_name, scientific_name, location dbl (8): ...1, count,
## duration, latitude, longitude, count_tot, month, year date (1): date time (1):
## time
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
year_data <- group_by(MBT_ebird, year)
summarize(year_data, sum(count))
## # A tibble: 13 × 2
## year `sum(count)`
## <dbl> <dbl>
## 1 2003 49
## 2 2004 1116
## 3 2009 25
## 4 2013 151
## 5 2014 9303
## 6 2015 3219
## 7 2016 379
## 8 2017 6102
## 9 2018 1738
## 10 2019 677
## 11 2020 8941
## 12 2021 3713
## 13 2022 1371
The year you observed the most birds was 2014 when you observed 9303 birds
##2. In that year how many different species of birds did I observe?
species_year <- filter(MBT_ebird, year == 2014)
mutate(species_year, SpeciesNum = n_distinct(scientific_name))
## # A tibble: 1,672 × 15
## ...1 list_ID commo…¹ scien…² date time count durat…³ locat…⁴ latit…⁵
## <dbl> <chr> <chr> <chr> <date> <tim> <dbl> <dbl> <chr> <dbl>
## 1 15 S209644… Greate… Anser … 2014-12-20 09:30 30 150 US-MO 38.9
## 2 45 S209644… Canada… Branta… 2014-12-20 09:30 45 150 US-MO 38.9
## 3 50 S178557… Canada… Branta… 2014-04-12 08:45 2 120 US-MO 38.7
## 4 51 S210255… Canada… Branta… 2014-12-25 10:30 8 120 US-MO 38.7
## 5 52 S167719… Canada… Branta… 2014-02-02 16:00 178 30 US-MO 38.6
## 6 53 S165368… Canada… Branta… 2014-01-27 14:30 70 45 US-MO 38.6
## 7 54 S172237… Canada… Branta… 2014-02-27 08:40 56 45 US-MO 38.6
## 8 55 S172940… Canada… Branta… 2014-03-04 08:15 30 45 US-MO 38.6
## 9 56 S173343… Canada… Branta… 2014-03-06 08:20 8 55 US-MO 38.6
## 10 57 S173450… Canada… Branta… 2014-03-07 08:20 38 55 US-MO 38.6
## # … with 1,662 more rows, 5 more variables: longitude <dbl>, count_tot <dbl>,
## # month <dbl>, year <dbl>, SpeciesNum <int>, and abbreviated variable names
## # ¹common_name, ²scientific_name, ³duration, ⁴location, ⁵latitude
That year you observed 210 unique species of birds
##3. In which state did I most frequently observe Red-winged Blackbirds?
state_data <- filter(MBT_ebird, scientific_name == "Agelaius phoeniceus")
state_data2014 <- filter(state_data, year == 2014)
state_dataGrouped <- state_data2014 %>% group_by(location)
Missouri is the state you most frequently observed red-winged blackbirds
Mean_data <- filter(MBT_ebird, duration > 5, duration < 200)
mutated_Mean_data <- Mean_data %>% mutate(rate = n_distinct(common_name)/duration)
mutated_Mean_data2 <- mutated_Mean_data %>% group_by(year) %>%
mutate(year_mean = mean(rate))
View(mutated_Mean_data2)
top10table <- MBT_ebird %>% count(scientific_name) %>% arrange(by = (desc(n))) %>% slice_head(n = 10)
top10table
## # A tibble: 10 × 2
## scientific_name n
## <chr> <int>
## 1 Cardinalis cardinalis 209
## 2 Zenaida macroura 170
## 3 Cyanocitta cristata 168
## 4 Turdus migratorius 152
## 5 Anas platyrhynchos 139
## 6 Sturnus vulgaris 126
## 7 Branta canadensis 125
## 8 Spinus tristis 122
## 9 Zonotrichia albicollis 116
## 10 Melanerpes carolinus 110