Skip to content

Commit

Permalink
hw update
Browse files Browse the repository at this point in the history
  • Loading branch information
jmledford3115 committed Mar 3, 2024
1 parent b540bbf commit 5441ac5
Show file tree
Hide file tree
Showing 3 changed files with 497 additions and 62 deletions.
Binary file modified .DS_Store
Binary file not shown.
66 changes: 4 additions & 62 deletions homework/lab13_hw.Rmd → homework/hw13.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,94 +33,36 @@ We will use two separate data sets for this homework.
2. The second data set is from Brandell, Ellen E (2021), Serological dataset and R code for: Patterns and processes of pathogen exposure in gray wolves across North America, Dryad, [Dataset](https://doi.org/10.5061/dryad.5hqbzkh51).

1. Load the `grizzly` data and evaluate its structure.
```{r}
grizzly <- read_csv(here("lab13", "data", "bear-sightings.csv"))
```

```{r}
summary(grizzly)
```

2. Use the range of the latitude and longitude to build an appropriate bounding box for your map.
```{r}
lat <- c(55.02, 70.37)
long <- c(-131.3, -166.2)
bbox <- make_bbox(long, lat, f = 0.05)
```


3. Load a map from `stamen` in a terrain style projection and display the map.
```{r}
map1 <- get_map(bbox, maptype = "terrain", source = "stamen")
```

```{r}
ggmap(map1)
```

4. Build a final map that overlays the recorded observations of grizzly bears in Alaska.
```{r}
ggmap(map1) +
geom_point(data = grizzly, aes(longitude, latitude), size=0.8) +
labs(x = "Longitude", y = "Latitude", title = "Ursos arctos")
```


Let's switch to the wolves data. Brandell, Ellen E (2021), Serological dataset and R code for: Patterns and processes of pathogen exposure in gray wolves across North America, Dryad, [Dataset](https://doi.org/10.5061/dryad.5hqbzkh51).

5. Load the data and evaluate its structure.
```{r}
wolves <- read_csv(here("lab12", "data", "wolves_data", "wolves_dataset.csv"))
```

```{r}
glimpse(wolves)
```

6. How many distinct wolf populations are included in this study? Mae a new object that restricts the data to the wolf populations in the lower 48 US states.
```{r}
wolves %>% count(pop)
```

```{r}
us_wolves <-
wolves %>%
filter(pop %in% c("GTNP", "MEXICAN", "MI", "MT", "SNF", "YNP"))
```

7. Use the range of the latitude and longitude to build an appropriate bounding box for your map.
```{r}
us_wolves %>%
select(lat, long) %>%
summary()
```

```{r}
lat <- c(33.69, 47.75)
long <- c(-110.99, -86.82)
bbox2 <- make_bbox(long, lat, f = 0.05)
```

8. Load a map from `stamen` in a `terrain-lines` projection and display the map.
```{r}
map2 <- get_map(bbox2, maptype = "terrain-lines", source = "stamen")
```

```{r}
ggmap(map2)
```

9. Build a final map that overlays the recorded observations of wolves in the lower 48 states.
```{r}
ggmap(map2) +
geom_point(us_wolves, mapping=aes(x=long, y=lat), size=2)+
labs(x = "Longitude", y = "Latitude", title = "Wolves in the Lower 48")
```


10. Use the map from #9 above, but add some aesthetics. Try to `fill` and `color` by population.
```{r}
ggmap(map2) +
geom_point(us_wolves, mapping=aes(x=long, y=lat, fill=pop, color=pop), size=3)+
labs(x = "Longitude", y = "Latitude", title = "Wolves in the Lower 48")
```


## Push your final code to GitHub!
Please be sure that you check the `keep md` file in the knit preferences.
493 changes: 493 additions & 0 deletions homework/hw13.html

Large diffs are not rendered by default.

0 comments on commit 5441ac5

Please sign in to comment.