install.packages("dplyr")
library(dplyr)
library(ggplot2)
mammals <- mammal_data
mammals
mammals %>%
  ggplot(aes(x=gestation.mo., y=weaning.mo.)) +
  geom_point() +
  geom_smooth(method = 'loess')
mammals %>%
    ggplot(aes(x=max..life.mo., y=weaning.mo.)) +
    geom_point() +
    geom_smooth(method='loess', alpha=0.5)
mammals %>%
    ggplot(aes(x=AFR.mo., y = weaning.mo.)) +
    geom_point() +
    geom_smooth(method='loess', alpha=0.5)
mammals %>%
    group_by(order) %>%
    tally() %>%
    filter(n > 30)
orders <- mammals %>%
    filter(order == 'Artiodactyla' | order == 'Carnivora' | order == 'Cetacea' | order == 'Insectivora' | order == 'Lagomorpha' | order == 'Primates' | order == 'Rodentia' )
orders
orders %>%
    ggplot(aes(x=gestation.mo., y=weaning.mo.)) +
    geom_point() +
    geom_smooth(method='loess', alpha=0.5)

NICE TREND!

orders %>%
    ggplot(aes(x=AFR.mo., y=weaning.mo.)) +
    geom_point() +
    geom_smooth(method='loess', alpha=0.5) +
    facet_wrap(~ order)
orders %>%
    mutate(offspring.year = litter.size * litters.year) %>% 
    ggplot(aes(x=offspring.year, y=gestation.mo., color = order)) +
    geom_point() +
    geom_smooth(method='loess', alpha=0.5)
orders %>%
    mutate(offspring.year = litter.size * litters.year) %>% 
    ggplot(aes(x=offspring.year, y=gestation.mo.)) +
               geom_point() +
    geom_smooth()

NICE TREND TOO!

orders %>%
    filter(mass.g. > 50000) %>% 
    ggplot(aes(x=mass.g., y=newborn.g.)) +
    geom_point() +
    geom_smooth()
orders %>%
    filter(order == "Rodentia") %>% 
    ggplot(aes(x=AFR.mo., y=max..life.mo.)) +
    geom_point() +
    geom_smooth(method='loess', alpha=0.5) +
    facet_wrap(~ order) +
    team_theme()
library(ggthemes)
team_theme <- function() {list(

    theme(axis.line = element_line(color = "black"),
          text = element_text(size=8, family="Times"),
          panel.background=element_rect(fill='white', color='black'),
          panel.grid.major=element_blank(),
          panel.grid.minor=element_blank(),
          plot.title=element_text(color="black", size=14, hjust=0.5),
          legend.text=element_text(size=12, family="Times")),
    scale_colour_colorblind()
)}
install.packages("broom")
library(broom)
fit <- glm(gestation.mo. ~ weaning.mo. + AFR.mo. + max..life.mo. + litter.size + litters.year, data=orders)
tidy(fit, conf.int=TRUE)
0.185-0.132
0.132-0.0797


UofTCoders/eeb430.2017.Python documentation built on May 28, 2019, 3:19 p.m.