Task Abstraction

In this assignment I create action-target pairs to help me visualize different aspects of my data.
Author

Alexis Means

Published

February 5, 2025

Action-Target Pairs

Proportion of Observed Families

The first two action-target pairs that I want to achieve are similar. With the first I want to identify attributes of my sampled vegetation by identifying how many counts of each family were observed throughout the course of my field season. I also want to compare the attributes by recognizing how many were observed in each family and which of these families has the most observations. My second graph will do something similar, however instead of identifying and comparing families, I want to observe and compare the species.

  1. identify attributes (top observed families)

  2. Compare attributes (# of observations in each family)

Code
#Clean the comp dataset and create a new column for family proportions
fam_prop<- comp %>%
  mutate(spp_code = str_trim(spp_code)) %>%             
  filter(!str_to_lower(spp_code) %in%                   
           str_to_lower(c("Litter", "Water", "Lichen", "Rocks", "Earth"))) %>% 
  left_join(plants, by = "spp_code") %>% 
  count(Family) %>% 
  arrange(n) %>% 
  mutate(proportions = n/sum(n)* 100) %>% 
  rename(fam_count = n)

#create a new object with the top 10 species in descending order
top_fam <-  fam_prop %>% 
  arrange(desc(proportions)) %>% 
  slice_head(n = 10)

#create boxplot of the top 10 families
ggplot(top_fam, aes(x = fct_reorder(Family, -proportions), y = proportions, fill = Family)) +
  geom_bar(stat = "identity") +
  scale_fill_viridis_d(option = "viridis") + 
  labs(
    x = "Family",
    y = "Proportion (%)",
    title = "Top 10 Families by Proportion"
  ) +
  theme_minimal() +
  theme(
    axis.text.x = element_text(angle = 45, hjust = 1),
    legend.position = "none")

Proportion of Observed Species

Along with the action-target pairs that I mentioned from the first graph, this graph also identifies attributes of each species by highlighting invasive species in red and native species in blue.

  1. identify attributes (top observed species)

  2. Compare attributes (# of observations for each species, as well as native vs invasive species)

  3. identify attributes (native species and invasive species)

Code
#Clean the comp dataset and create a new column for species proportions
spp_num <- comp %>%
  mutate(spp_code = str_trim(spp_code)) %>%              
  filter(!str_to_lower(spp_code) %in%                   
           str_to_lower(c("Litter", "Water", "Lichen", "Rocks", "Earth"))) %>%
  count(spp_code) %>%
  arrange(n) %>%
  left_join(plants, by = "spp_code") %>%
  mutate(proportion = (n / sum(n)) * 100) %>% 
  rename(spp_count = n, spp_code_prop = proportion) 

#Create new object with the top 10 species observed in descending order
top_spp <- spp_num %>%
  arrange(desc(spp_code_prop)) %>%
  slice_head(n = 10)

#Create a boxplot of the top 10 species 
ggplot(top_spp, aes(x = fct_reorder(spp_code, -spp_code_prop), y = spp_code_prop, fill = status)) +
  geom_bar(stat = "identity") +
  theme_minimal() +
  labs(
    x = "Species Code",
    y = "Proportion (%)",
    title = "Top 20 Species by Proportion",
    fill = "status"
  )+
  theme(
    axis.text.x = element_text(angle = 45, hjust = 1),
    legend.position = "none")

Status of Observed Species

For my last action-target pair I would like to compare the features of the species that I observed throughout the summer. Specifically I want to know the proportion of native vs invasive species that were observed in total.

  1. compare features (invasive vs native species)
Code
#Clean the comp dataset and create a new column for status proportions
inv <- comp %>%
  mutate(spp_code = str_trim(spp_code)) %>%             
  filter(!str_to_lower(spp_code) %in%                   
           str_to_lower(c("Litter", "Water", "Lichen", "Rocks", "Earth"))) %>%
  left_join(plants, by = "spp_code") %>%
  count(status) %>%
  arrange(n) %>% 
  mutate(proportion = (n / sum(n)) * 100)

#Create a piechart comparing the native vs invasive species
ggplot(inv, aes(x = "", y = proportion, fill = status)) +
  geom_bar(stat = "identity", width = 1) +
  coord_polar("y") +
  labs(title = "Species Status") +
  theme_void()