Introduction

This report explores patterns in wildlife conservation status across different habitats and regions. Using the IUCN conservation status, habitat, and region variables, I will examine how species are distributed across habitats, how conservation status varies by region, and how conservation status differs among habitat types. These visualizations aim to identify patterns in the distribution of wildlife species and their conservation status within the dataset.

Load packages

# load packages for data import, cleaning, and visualization 
library(tidyverse)
library(here)
library(ggbeeswarm)
library(skimr)
library(janitor)

Data Preparation

Before conducting analysis, the dataset was cleaned and a new population estimate column was created. I used clean_names() to standardize the column names and make them easier to work with in R. The new column allows population estimates to be used in a numeric visualization.

# import the original endangered species dataset 
endangeredSpecies <- read_csv(here("data", "endangeredSpecies.csv"))

# standardize column names by converting them to lowercase and replacing spaces with underscores 
cleanSpecies <- clean_names(endangeredSpecies)

# create a numeric population estimate column
# extract the first number from each population estimate
# values such as "unknown" become NA 
cleanSpecies <- cleanSpecies %>% 
  mutate(
    population_numeric = parse_number(population_estimate)
  )

# save the cleaned dataset as a new CSV file 
write_csv(cleanSpecies, here("data", "cleanSpecies.csv"))

Plot 1. How many species are found in each habitat?

# count the number of species recorded in each habitat using a horizontal bar chart
cleanSpecies %>%
  ggplot(aes(x = habitat)) +
  geom_bar(fill = "darkseagreen") +
  labs(
    title = "Distribution of Wildlife Species by Habitat",
    x = "Habitat",
    y = "Number of Species",
    caption = "Figure 1. Number of wildlife species recorded in each habitat type. Bar lengths represent the number of observations in the dataset."
  ) +
  coord_flip()+
  theme_minimal() +
  theme(
    # left-align the caption for readability
    plot.caption = element_text(
      size = 8,
      hjust = 0
    )
  )

Plot 2. How does conservation status vary by region?

# compare the number of species in each conservation category across geographic regions 
cleanSpecies %>%
  ggplot(aes(x = region, fill = iucn_status)) +
  geom_bar() +
  labs(
    title = "Wildlife Conservation Status Across Regions",
    x = "Geographic Region",
    y = "Number of Species",
    fill = "IUCN Status",
    caption = "Figure 2. Species counts by IUCN status across geographic regions. Colors represent conservation categories."
  ) +
  coord_flip() +
  theme_minimal() +
  theme(
    # left-align the caption for readability
    plot.caption = element_text(
      size = 8, 
      hjust = 0
    )
  )

Plot 3. How do population estimates vary across habitats?

# show the distribution of population estimates in each habitat using a violin plot 
cleanSpecies %>%
  ggplot(aes(x = habitat, 
             y = population_numeric, 
             fill = habitat)) +
  geom_violin() +
  labs(
    title = "Population Estimates Across Habitats",
    x = "Habitat",
    y = "Approximate Population Estimate",
    caption = "Figure 3. Distribution of approximate population estimates across habitat types. Ranges represented by their lower bound."
  ) +
  # use a logarithmic scale to display widely varying estimates 
  scale_y_log10() +
  # angle habitat labels to reduce overlap 
  theme(
    axis.text.x = element_text(
      angle = 45,
      hjust = 1),
    # adjust caption size and alignment
    plot.caption = element_text(
      size = 8,
      hjust = 0
    ),
    # remove the legend 
    legend.position = "none"
  )

Analysis

The comparisons reveal differences in how wildlife species are represented across habitats and geographic regions. Tropical forests contain the largest number of recorded species in the dataset. The regional comparison shows that Asia has the highest overall species count, with different conservation status categories represented across regions. The violin plot shows that population estimates vary widely within habitats, with some species having much larger estimated populations than others. These comparisons highlight variation in species representation, conservation status, and population estimates. However, the results reflect only the species included in this dataset, and population estimates are approximate because some original values were ranges or upper limits.

References

CSV Preview. (n.d.). Endangered species IUCN. https://csvpreview.com/data/animals-nature/endangered-species-iucn