Capstone project for Data Carpentry course.
library(dplyr)
library(ggplot2)
surveys <- read.csv("http://kbroman.org/datacarp/portal_data_joined.csv")
There are 13 columns and 34786 rows.
Boxplots of weight by sex, omitting individuals with missing sex.
surveys %>% select(weight, sex) %>%
filter(sex != "", !is.na(weight)) %>%
ggplot() + geom_boxplot(aes(x=sex, y=weight))
surveys %>% filter(!is.na(hindfoot_length)) %>%
ggplot() + geom_histogram(aes(x=hindfoot_length), bins=150)
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 ~ .)
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 |
counts <- surveys %>% filter(species_id == "DM") %>%
filter(plot_type=="Rodent Exclosure") %>%
group_by(year) %>%
tally()
counts %>% ggplot(aes(x=year, y=n)) + geom_line()