Capstone project for Data Carpentry course.

``````library(dplyr)
library(ggplot2)

There are 13 columns and 34786 rows.

## 2: Boxplots of weight by sex

Boxplots of weight by sex, omitting individuals with missing sex.

``````surveys %>% select(weight, sex) %>%
filter(sex != "", !is.na(sex)) %>%
ggplot() + geom_boxplot(aes(x=sex, y=weight))``````
``## Warning: Removed 856 rows containing non-finite values (stat_boxplot).``

## 3. Histogram of hindfoot lengths

``````surveys %>% filter(!is.na(hindfoot_length)) %>%
ggplot() + geom_histogram(aes(x=hindfoot_length), bins=150)``````

## 4. scatterplots of hindfoot length vs weight for 3 species

``````surveys %>% filter(species_id %in% c("DM", "DO", "DS")) %>%
filter(!is.na(weight), !is.na(hindfoot_length)) %>%
ggplot(aes(x=hindfoot_length, y=weight)) +
geom_point(aes(color=species_id)) + facet_grid(species_id ~ .)``````

## 5. Table with counts of “DM” by plot_type in 1977

``````counts1977 <- surveys %>% filter(species_id == "DM", year==1977) %>%
group_by(plot_type) %>%
tally() %>%
select(plot_type, n)
knitr::kable(counts1977)``````
plot_type n
Control 108
Long-term Krat Exclosure 36
Rodent Exclosure 31
Short-term Krat Exclosure 71
Spectab exclosure 18

## 6. Plot of counts in “Rodent Exclosure” plots over time

``````counts <- surveys %>% filter(species_id == "DM") %>%
filter(plot_type=="Rodent Exclosure") %>%
group_by(year) %>%
tally()
counts %>% ggplot(aes(x=year, y=n)) + geom_line()``````