bb <- read.csv("BlackBear.csv") %>%
rename(Age="Age..yr.",
Length="Body.length..cm.",
Chest="Chest.girth..cm.",
Weight="Body.weight..kg.") %>%
mutate(Sex=plyr::mapvalues(Sex,from=c("FEMALE","MALE"),
to=c("Female","Male")),
Date=as.Date(Date,format="%m/%d/%Y"),
Year=lubridate::year(Date),
Mon=lubridate::month(Date,label=TRUE))
head(bb)
bb_gt3 <- filter(bb,Age>=3)
The data for this graph was sourced from a study in which measurements of Black bears (Ursus americanus) were taken from 2000 to 2012. Bears were measured throughout Florida, on both public and private land, to show the best representation of the black bear population. Three measurements were taken of each bear: body length, chest girth, and body weight. A total of 203 females and 304 males were measured, from ages 0 to twenty years old. Food source varied among bears, between what was considered a natural diet, to what was considered a diet consisting mainly of human food.
This graph is investigating whether body weight differs in black bears depending on their sex and diet. Only sexually mature bears (>3 years) were selected for this graph. Incuding younger bears would skew the graphs (nearly half of the bears measured were under the age of 3), and could potentially cause the reader to think there is a prevalence of small black bears, when in fact they are just bears that are not fully grown.
p <- ggplot(data=bb_gt3, mapping=aes(x=Weight)) +
geom_histogram(color="gray30", fill="gray50", binwidth = 10, boundary=0, closed="left") +
facet_grid(rows=vars(Food.habit),cols=vars(Sex),labeller= labeller(Food.habit=c("Human"="From Humans",
"Natural"="Natural"))) +
scale_x_continuous(name="Weight (kg)",breaks=seq(0,250,50),expand=expansion(mult=c(0.1,0.01))) +
scale_y_continuous(name="Number of Bears",expand=expansion(mult=c(0,0.05))) +
labs(title="Body Weight of Florida Black Bears by Sex and Diet",
subtitle="From 2000 to 2012",
caption="https://fwspubs.org/doi/full/10.3996/082018-JFWM-076") +
theme_bw() +
theme(panel.grid.major.x = element_blank(),panel.grid.minor.x=element_blank(),
plot.caption = element_text(color = "gray50", size=7,vjust=-2,hjust=1.13),strip.text=element_text(size=15),plot.title = element_text(size=18),plot.subtitle=element_text(size=12),axis.title.x=element_text(size=15),axis.title=element_text(size=15))
p
The graph shows that male black bears tend to be larger in weight than female black bears. It also shows that, the largest sample of bears taken were male black bears whose diet consisted of primarily human sourced food. There is no clear difference between bear weight and diet, regardless of sex.
I chose to facet this graph, as I felt it would more clearly show differences in weight between the two sexes and diet sources. I put sex as columns, as it was my primary focus, and food source as rows, as they were my secondary focus. I used geom_histogram because it could best show how many bears were in each weight class. Binwidth was set to 10 to best show variation. I removed all x axis gridlines because they are not helpful in understanding histograms. The fill to the bars was set to gray, as I felt the facet variable labels made everything clear enough without using different colors. Lastly, the caption was made smaller, lighter in color, and was moved slightly to the side, so it did not distract from the x axis title.