Explore rodent data from the Portal Project.
List of tasks:
library(dplyr)
library(ggplot2)
data <- read.csv("https://ndownloader.figshare.com/files/2292172")
head(data)
## record_id month day year plot_id species_id sex hindfoot_length weight
## 1 1 7 16 1977 2 NL M 32 NA
## 2 2 7 16 1977 3 NL M 33 NA
## 3 3 7 16 1977 2 DM F 37 NA
## 4 4 7 16 1977 7 DM M 36 NA
## 5 5 7 16 1977 3 DM M 35 NA
## 6 6 7 16 1977 1 PF M 14 NA
The data includes 49 species.
Summarize data for number of occurrences per year and per species.
time_series <- data %>%
group_by(species_id, year) %>%
summarize(count = n())
## `summarise()` has grouped output by 'species_id'. You can override using the `.groups` argument.
head(time_series)
## # A tibble: 6 × 3
## # Groups: species_id [1]
## species_id year count
## <chr> <int> <int>
## 1 "" 1977 16
## 2 "" 1978 56
## 3 "" 1979 61
## 4 "" 1980 40
## 5 "" 1981 55
## 6 "" 1982 14
Plot time series.
ggplot(time_series, aes(x = year, y = count)) +
geom_line() +
facet_wrap(~species_id)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?