Instructions

Answer the following questions and/or complete the exercises in RMarkdown. Please embed all of your code and push the final work to your repository. Your report should be organized, clean, and run free from errors. Remember, you must remove the # for any included code chunks to run. Any plots must have appropriate titles and aesthetics.

Load the tidyverse

library("tidyverse")
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.0     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.2     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
options(scipen=999) #turn off scientific notation

Data

Database of vertebrate home range sizes. Reference: Tamburello N, Cote IM, Dulvy NK (2015) Energy and the scaling of animal space use. The American Naturalist 186(2):196-211. http://dx.doi.org/10.1086/682070.
Data: http://datadryad.org/resource/doi:10.5061/dryad.q5j65/1

1. Load the data into a new object called homerange.

homerange <- read_csv("data/Tamburelloetal_HomeRangeDatabase.csv")
## Rows: 569 Columns: 24
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (16): taxon, common.name, class, order, family, genus, species, primarym...
## dbl  (8): mean.mass.g, log10.mass, mean.hra.m2, log10.hra, dimension, preyma...
## 
## ℹ 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.

2. What is the structure of the homerange data? Does it have any NA’s? Do a quick exploratory analysis of your choice below.

glimpse(homerange)
## Rows: 569
## Columns: 24
## $ taxon                      <chr> "lake fishes", "river fishes", "river fishe…
## $ common.name                <chr> "american eel", "blacktail redhorse", "cent…
## $ class                      <chr> "actinopterygii", "actinopterygii", "actino…
## $ order                      <chr> "anguilliformes", "cypriniformes", "cyprini…
## $ family                     <chr> "anguillidae", "catostomidae", "cyprinidae"…
## $ genus                      <chr> "anguilla", "moxostoma", "campostoma", "cli…
## $ species                    <chr> "rostrata", "poecilura", "anomalum", "fundu…
## $ primarymethod              <chr> "telemetry", "mark-recapture", "mark-recapt…
## $ N                          <chr> "16", NA, "20", "26", "17", "5", "2", "2", …
## $ mean.mass.g                <dbl> 887.00, 562.00, 34.00, 4.00, 4.00, 3525.00,…
## $ log10.mass                 <dbl> 2.9479236, 2.7497363, 1.5314789, 0.6020600,…
## $ alternative.mass.reference <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ mean.hra.m2                <dbl> 282750.00, 282.10, 116.11, 125.50, 87.10, 3…
## $ log10.hra                  <dbl> 5.4514026, 2.4504031, 2.0648696, 2.0986437,…
## $ hra.reference              <chr> "Minns, C. K. 1995. Allometry of home range…
## $ realm                      <chr> "aquatic", "aquatic", "aquatic", "aquatic",…
## $ thermoregulation           <chr> "ectotherm", "ectotherm", "ectotherm", "ect…
## $ locomotion                 <chr> "swimming", "swimming", "swimming", "swimmi…
## $ trophic.guild              <chr> "carnivore", "carnivore", "carnivore", "car…
## $ dimension                  <dbl> 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3…
## $ preymass                   <dbl> NA, NA, NA, NA, NA, NA, 1.39, NA, NA, NA, N…
## $ log10.preymass             <dbl> NA, NA, NA, NA, NA, NA, 0.1430148, NA, NA, …
## $ PPMR                       <dbl> NA, NA, NA, NA, NA, NA, 530, NA, NA, NA, NA…
## $ prey.size.reference        <chr> NA, NA, NA, NA, NA, NA, "Brose U, et al. 20…
names(homerange)
##  [1] "taxon"                      "common.name"               
##  [3] "class"                      "order"                     
##  [5] "family"                     "genus"                     
##  [7] "species"                    "primarymethod"             
##  [9] "N"                          "mean.mass.g"               
## [11] "log10.mass"                 "alternative.mass.reference"
## [13] "mean.hra.m2"                "log10.hra"                 
## [15] "hra.reference"              "realm"                     
## [17] "thermoregulation"           "locomotion"                
## [19] "trophic.guild"              "dimension"                 
## [21] "preymass"                   "log10.preymass"            
## [23] "PPMR"                       "prey.size.reference"

3. Which animal groups are represented in the data? Make a plot that shows the number in each class.

homerange %>% 
  ggplot(mapping=aes(x=class))+
  geom_bar(mapping=aes(fill=class))+
  labs(title="Number of Species by Class",
       x="Class",
       y="Number of Species")

4. Are there more carnivores or herbivores represented in the data? Make a plot that shows the number in each trophic guild.

homerange %>% 
  ggplot(mapping=aes(x=trophic.guild))+
  geom_bar(mapping=aes(fill=trophic.guild))+
  labs(title="Number of Species by Trophic Guild",
       x="Trophic Guild",
       y="Number of Species")

5. Which herbivorous mammals have homeranges greater than 1,000,000 m²? Show only the common name, order, mean homerange size, and mean body mass. Arrange the data in descending order by homerange size and show only the top 10 species.

homerange %>%
filter(class == "mammalia",
trophic.guild == "herbivore",
mean.hra.m2 > 1000000) %>%
select(common.name, order, mean.hra.m2, mean.mass.g) %>%
arrange(desc(mean.hra.m2)) %>%
slice_head(n = 10)
## # A tibble: 10 × 4
##    common.name           order        mean.hra.m2 mean.mass.g
##    <chr>                 <chr>              <dbl>       <dbl>
##  1 reindeer              artiodactyla 3550830977      102059.
##  2 African bush elephant proboscidea  1753759352     4000000.
##  3 greater kudu          artiodactyla 1070039969      197315.
##  4 American bison        artiodactyla  265778594.     629999.
##  5 giraffe               artiodactyla  136536888     1339985.
##  6 Asian elephant        proboscidea   109999320.    4000000.
##  7 moose                 artiodactyla   93825308.     307227.
##  8 red deer              artiodactyla   74865202.     234758.
##  9 goat                  artiodactyla   64528267.      51000.
## 10 common eland          artiodactyla   52399845.     635038.

6. Which two species have the largest and smallest homerange sizes?

homerange %>%
  select(common.name, mean.hra.m2) %>%
  arrange(desc(mean.hra.m2)) %>% 
  slice_head()
## # A tibble: 1 × 2
##   common.name mean.hra.m2
##   <chr>             <dbl>
## 1 reindeer     3550830977
homerange %>%
  select(common.name, mean.hra.m2) %>%
  arrange(desc(mean.hra.m2)) %>% 
  slice_tail()
## # A tibble: 1 × 2
##   common.name mean.hra.m2
##   <chr>             <dbl>
## 1 rusty goby         0.03

7. Which carnivorous mammals have the largest homeranges?

homerange %>% 
  select(common.name, class, trophic.guild, mean.hra.m2) %>%
  filter(class=="mammalia", trophic.guild=="carnivore") %>% 
  arrange(desc(mean.hra.m2))
## # A tibble: 80 × 4
##    common.name   class    trophic.guild mean.hra.m2
##    <chr>         <chr>    <chr>               <dbl>
##  1 cheetah       mammalia carnivore      815060788.
##  2 leopard       mammalia carnivore      504940261.
##  3 caracal       mammalia carnivore      376634414 
##  4 wolverine     mammalia carnivore      361917847.
##  5 cougar        mammalia carnivore      312003884.
##  6 Eurasian lynx mammalia carnivore      181042276.
##  7 Canada lynx   mammalia carnivore       82748475.
##  8 jaguar        mammalia carnivore       82735139.
##  9 jaguarundi    mammalia carnivore       67079528.
## 10 tiger         mammalia carnivore       53583367.
## # ℹ 70 more rows

8. Is there a relationship between body mass and homerange size? Make a scatterplot to show this relationship. Be sure to include appropriate labels and a title.

homerange %>%
  ggplot(mapping=aes(x=log10.mass, y=log10.hra))+
  geom_point(mapping=aes(color=class))+
  geom_smooth(method="lm", se=FALSE)+
  labs(title="Relationship between Body Mass and Homerange Size",
       x="Body Mass (g)",
       y="Mean Homerange Size (m^2)")
## `geom_smooth()` using formula = 'y ~ x'

9. Use filter to extract the data for only birds and mammals. Then make a plot that compares the homerange sizes of these two groups. Be sure to include appropriate labels and a title.

homerange %>%
filter(class == "aves" | class == "mammalia") %>%
ggplot(aes(x = class, y = log10.hra)) +
geom_boxplot(mapping=aes(fill=class)) +
labs(title = "Home Range Size for Birds vs Mammals",
x = "Class",
y = "log10(Home Range Area)")

10. Do one additional exploratory analysis of your choice. Before writing the code, write the question you are trying to answer. The question should be biologically meaningful and appropriate for the data. It must include at least one filter(), select(), and arrange().

Knit and Upload

Please knit your work as an .html file and upload to Canvas. Homework is due before the start of the next lab. No late work is accepted. Make sure to use the formatting conventions of RMarkdown to make your report neat and clean!