This project

This code is for the graphical analysis of percent observations of roosting and being in water at different time points.

Data prep

Read in data

captive.data = read.csv("2023 Chick Yards.csv", header=T)
names(captive.data)
##  [1] "YARD"               "Chick"              "Date"              
##  [4] "Image.."            "Time"               "Hour"              
##  [7] "In.H2O"             "Comfort.Behavior"   "Proxim.to.edge..m."
## [10] "Light.Dark"         "X"

Install packages

Modify variables

Hour

# get rid of NAs in Hour
captive.data = captive.data %>%
  filter(!is.na(Hour))

# convert hour to factor with specific hours

captive.data = filter(captive.data, Hour %in%  c("100", "200", "300", "400", "500", "600", "1800", "1900", "2000", "2100", "2200", "2300", "2400"))
captive.data$time.factor <- factor(captive.data$Hour)
levels(captive.data$time.factor)
##  [1] "100"  "1800" "1900" "200"  "2000" "2100" "2200" "2300" "2400" "300" 
## [11] "400"  "500"  "600"

Plots

In.water (roosting) v time

While you can’t say anything about water usage at this point (talk about that), you can talk about how often animals that were in water were roosting.

# get rid of NAs in In.H20
water.data = captive.data %>%
  filter(!is.na(In.H2O))

# convert In.H2O to factors

water.data$water.factor = factor(water.data$In.H2O)
#levels(water.data$water.factor)

Plot roosting v time with absolute values

ggplot(water.data, aes(factor(time.factor, level=c('1800', '1900', '2000', '2100', '2200', '2300', '2400', '100', '200', '300', '400', '500', '600')), after_stat(count))) + 
  geom_bar(aes(fill = water.factor), position = "dodge") +
  labs(x="Hour of day",y="Number of observations roosting", fill = "In (1) or out (0) of water")

Plot roosting v time with proportions

# create a table with number of roosting observations per hour of day
water.table <- water.data %>% group_by(time.factor) %>%
  summarise(
    count.roost = n(),
    total.in.roost=sum(In.H2O),
    total.out.roost = (length(In.H2O) - sum(In.H2O)),
  )

# create table with proportion roosting in and out of water per hour

water.table = water.table %>%
  mutate(prop.in.roost = (total.in.roost / count.roost))

water.table = water.table %>%
  mutate(prop.out.roost = (total.out.roost / count.roost))

# create table with one column for roosting prop in and out}

water.table = gather(water.table, key="in.out.roost", value="proportion.roost", 5:6)
water.table
## # A tibble: 26 × 6
##    time.factor count.roost total.in.roost total.out.roost in.out.roost 
##    <fct>             <int>          <int>           <int> <chr>        
##  1 100                 194            160              34 prop.in.roost
##  2 1800                173             64             109 prop.in.roost
##  3 1900                177            101              76 prop.in.roost
##  4 200                 190            151              39 prop.in.roost
##  5 2000                206            153              53 prop.in.roost
##  6 2100                202            163              39 prop.in.roost
##  7 2200                212            183              29 prop.in.roost
##  8 2300                197            172              25 prop.in.roost
##  9 2400                190            160              30 prop.in.roost
## 10 300                 188            153              35 prop.in.roost
## # ℹ 16 more rows
## # ℹ 1 more variable: proportion.roost <dbl>
ggplot(water.table, aes(x = factor(time.factor, level=c('1800', '1900', '2000', '2100', '2200', '2300', '2400', '100', '200', '300', '400', '500', '600')), y = proportion.roost, fill = in.out.roost)) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(x="Hour of day",y="Proportion of observations roosting") +
  scale_fill_manual(name="In or out of water",labels=c("in", "out"), values=c("#F8766D", "#00BFC4"))

Comfort behavior

Plot comfort behavior v time with absolute values

Plot comfort behavior v time with proportions

###2023 Chick Yard Data

Davin Lopez

Stewart,S. 2020. INVESTIGATING CAUSE-SPECIFIC MORTALITY OF WHOOPING CRANE (GRUS AMERICANA) CHICKS AT NECEDAH NATIONAL WILDLIFE REFUGE. Thesis, Biology Dept, Univ WI Oshkosh